Hi, i have a algorithm that processes some input byte as the following:


Output Byte = DES-1(keyLeft, DES(keyRight, DES-1(keyLeft, inputByte)))



i try to use c# TripleDES class decryptor method to implement this algo but no luck. I either get my exception error of "bad data" or there is no output from the method. So i wonder if anybody know how to do DES decryption in c#.


byte[] inputByte = new byte[8];

byte[] key = new byte[24];

byte[] initVal = new byte[8];

byte[] outputByte = new byte[8];


//////////////////////////////////////////

// Some inititalization of key and inputByte.
// Actual value not shown here.

input Byte = ......
key = ......

Array.clear(initVal, 0, 8);



//////////////////////////////////////////


TripleDES tdes = TripleDES.Create();

tdes.Key = key;
tdes.IV = initVal;


ICryptoTransform ict = tdes.CreateDecryptor();
tdes.Mode = CipherMode.ECB;

outputByte = ict.TransformFinalBlock(inputByte, 0, 8);