Answer the question
In order to leave comments, you need to log in
How to decode C# rijndael-256 in PHP?
Given:
There is a certain program that sends data via API, encrypted by rijndaelManaged with a block length and a key of 256. There are no source codes for the
program, it was written a long time ago and everything has already been lost, only the part that sends the data remains. It needs to be decoded on the PHP side.
public static string EncryptMessage(byte[] text, string key)
{
RijndaelManaged rijndaelManaged = new RijndaelManaged();
rijndaelManaged.KeySize = 256;
rijndaelManaged.BlockSize = 256;
rijndaelManaged.Padding = PaddingMode.Zeros;
rijndaelManaged.Mode = CipherMode.CBC;
rijndaelManaged.Key = Encoding.Default.GetBytes(key);
rijndaelManaged.GenerateIV();
string str = "-[--IV-[-" + Encoding.Default.GetString(rijndaelManaged.IV);
ICryptoTransform encryptor = rijndaelManaged.CreateEncryptor(rijndaelManaged.Key, rijndaelManaged.IV);
byte[] inputBuffer = text;
return Convert.ToBase64String(Encoding.Default.GetBytes(Encoding.Default.GetString(encryptor.TransformFinalBlock(inputBuffer, 0, inputBuffer.Length)) + str));
}
rijndaelManaged.BlockSize = 256;
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question