【问题标题】:C# DES ECB Encryption OpenSSLC# DES ECB 加密 OpenSSL
【发布时间】:2019-09-27 21:13:44
【问题描述】:

我无法让我的加密与我从 OpenSSL 中获得的内容相匹配。 Mk.bin文件中的输入是一个十六进制值CA46E5A885D1E016150B5B64ECC11A43

以下是我的 openssl 命令:

openssl.exe enc -des-ecb -in C:\OpenSSL\Mk.bin -out C:\OpenSSL\MkOut.bin -nosalt -k TestKey0

我尝试匹配的 C# 函数是:

public static byte[] EncryptDES(byte[] clearData, byte[] key)
    {
        DES desEncrypt = new DESCryptoServiceProvider();
        desEncrypt.Mode = CipherMode.ECB;
        desEncrypt.Key = key;
        ICryptoTransform transForm = desEncrypt.CreateEncryptor();
        MemoryStream encryptedStream = new MemoryStream();
        CryptoStream cryptoStream = new CryptoStream(encryptedStream, transForm, CryptoStreamMode.Write);
        cryptoStream.Write(clearData, 0, clearData.Length);
        cryptoStream.FlushFinalBlock();
        return encryptedStream.ToArray();
    }

【问题讨论】:

    标签: c# openssl des ecb


    【解决方案1】:

    我找到了答案 -p put into openssl 显示它正在转换我的十六进制输入。当我在 c# 中使用转换后的键时,它输出了正确的值

    【讨论】:

      猜你喜欢
      • 2021-11-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-01-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多