0

I am having a problem getting my encryption to match what I am getting out of OpenSSL. The input in the Mk.bin file is a hex value of CA46E5A885D1E016150B5B64ECC11A43

The following is my openssl command:

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

And my C# function to attempt to match that is:

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();
    }
CEH
  • 5,701
  • 2
  • 16
  • 40

1 Answers1

0

I found the answer -p put into openssl shows me that it was converting my hex input. When I used the converted key in c#, it outputted the correct value