小编abh*_*hek的帖子

在.net中加密字符串并在python中解密

我正在尝试使用正常工作的 system.Security.Cryptography 加密密码 这是代码 (.Net)

if (clearText == null)
{
    clearText = "";
}
string EncryptionKey = "****";
byte[] clearBytes = Encoding.Unicode.GetBytes(clearText);
using (Aes encryptor = Aes.Create())
{
    Rfc2898DeriveBytes pdb = new Rfc2898DeriveBytes(EncryptionKey, new byte[] { 0x49, 0x76, 0x61, 0x6e, 0x20, 0x4d, 0x65, 0x64, 0x76, 0x65, 0x64, 0x65, 0x76 });
    encryptor.Key = pdb.GetBytes(32);
    encryptor.IV = pdb.GetBytes(16);
    using (MemoryStream ms = new MemoryStream())
    {
        using (CryptoStream cs = new CryptoStream(ms, encryptor.CreateEncryptor(), CryptoStreamMode.Write))
        {
            cs.Write(clearBytes, 0, clearBytes.Length);
            cs.Close();
        }
        clearText = Convert.ToBase64String(ms.ToArray()); …
Run Code Online (Sandbox Code Playgroud)

c# asp.net encryption cryptography python-3.x

0
推荐指数
1
解决办法
1529
查看次数

标签 统计

asp.net ×1

c# ×1

cryptography ×1

encryption ×1

python-3.x ×1