生成256位密钥Rijndael在PHP



下面的代码将成功生成用于加密的KEY。我如何在PHP中使用相同的salt和passkey来重新创建它,以生成一个KEY来解密消息?

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));
}

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

crypt支持Rijndael-256

相关内容

  • 没有找到相关文章

最新更新