C#DES ECB加密OpenSSL

问题描述 投票:0回答:1

我在使加密与从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个回答
0
投票

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

© www.soinside.com 2019 - 2024. All rights reserved.