I'm trying to adapt the following function from C# to PHP and I can't get it to work. I've already searched other threads, but couldn't find the right answer to solve my problem.
public static string Decrypt(string EncryptedText)
{
byte[] bytes = Encoding.ASCII.GetBytes("hello");
byte[] buffer = Convert.FromBase64String(EncryptedText);
byte[] rgbKey = new Rfc2898DeriveBytes("world", bytes).GetBytes(0x20);
ICryptoTransform transform = new RijndaelManaged { Mode = CipherMode.CBC }.CreateDecryptor(rgbKey, bytes);
MemoryStream stream = new MemoryStream(buffer);
CryptoStream stream2 = new CryptoStream(stream, transform, CryptoStreamMode.Read);
byte[] buffer4 = new byte[buffer.Length];
int count = stream2.Read(buffer4, 0, buffer4.Length);
stream.Close();
stream2.Close();
return Encoding.UTF8.GetString(buffer4, 0, count);
}
Any help appreciated. Thanks!