C# 3DES (Triple-DES) Test Vector
This post provides C# sample code for matching a test vector (known answer test).
3DES Settings:
- ECB Mode
- 192-bit key (i.e. 3 8-bit keys)
- ASCII Key Bytes: 1234567890123456ABCDEFGH
- ASCII Text to Encrypt: The quick brown fox jumped over the lazy dog
- Pads with zero bytes
- Hexadecimalized Encrypted Result:
13d4d3549493d2870f93c3e0812a06de467e1f9c0bfb16c0
70ede5cabbd3ca62f217a7ae8d47f2c7bf62eb309323b58b
C# Code:
string keyAscii = "1234567890123456ABCDEFGH"; byte[] key = ASCIIEncoding.ASCII.GetBytes(keyAscii); byte[] clearText = ASCIIEncoding.ASCII.GetBytes("The quick brown fox jumped over the lazy dog"); TripleDESCryptoServiceProvider des = new TripleDESCryptoServiceProvider(); des.KeySize = 192; des.Key = key; des.Mode = CipherMode.ECB; des.Padding = PaddingMode.Zeros; byte[] cipherText = des.CreateEncryptor().TransformFinalBlock(clearText, 0, clearText.Length);
3DES Code to match this test vector in other languages:
ASP: 3DES Test Vector
SQL Server: 3DES Test Vector
C#: 3DES Test Vector
C++: 3DES Test Vector
MFC: 3DES Test Vector
C: 3DES Test Vector
Delphi: 3DES Test Vector
Visual FoxPro: 3DES Test Vector
Java: 3DES Test Vector
Perl: 3DES Test Vector
PHP: 3DES Test Vector
Python: 3DES Test Vector
Ruby: 3DES Test Vector
VB.NET: 3DES Test Vector
Visual Basic: 3DES Test Vector
VBScript: 3DES Test Vector
admin
0
Tags :