Skip to content
Advertisement

Decrypt data using PHP that was encrypted with Rijndael (C#)

my task is to decrypt data encrypted in C# using Php. I try to use the phpseclib library. So here is the existing code that is used in C# to encrypt :

JavaScript

It is not possible to change this code. So here is what I’ve tried using phpseclib :

JavaScript

At this point, the code breaks with an Exception “Derived key too long” raised on setPassword() call.

I tried many things such as changing blockLength and KeyLenghth and not using setPassword()

JavaScript

with no notable changes.

I have little experience in decrypting and ciphers, so I digged some info on the C# code used. Looking at the Rijndael class here https://docs.microsoft.com/en-us/dotnet/api/system.security.cryptography.rijndael?view=netframework-4.8. I tried several things with not much ideas on what I should look. I don’t even know if there is possible to use Phpseclib to decrypt data made by this C# code.

Thanks to every people who could give me some guidance.

Advertisement

Answer

It looks like https://github.com/phpseclib/phpseclib/issues/1447#issuecomment-580594929 might answer your question. Quoting it:

According to https://crypto.stackexchange.com/q/22271/4520 PasswordDeriveBytes implements a customized version of PBKDF1.

Try this:

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement