-1

下面的代码将成功生成 KEY 进行加密。如何使用相同的盐和密码在 PHP 中重新创建它以生成密钥以解密消息?

public static string GenerateKey(string passkey)
{
    var myAlg = new RijndaelManaged()
    {
         Padding = PaddingMode.PKCS7,
         Mode = CipherMode.CBC,
         KeySize = 256,
         BlockSize = 256,
    };
    byte[] salt = Encoding.ASCII.GetBytes("Some salt value");
    Rfc2898DeriveBytes keys = new Rfc2898DeriveBytes(passkey, salt);
    myAlg.Key = keys.GetBytes(myAlg.KeySize / 8);
    return (Encoding.ASCII.GetString(myAlg.Key));
}
4

1 回答 1

-2

检查这个:http ://www.php.net/manual/en/book.mcrypt.php

Mcrypt 支持 Rijndael-256

于 2013-06-19T06:37:01.430 回答