128bit decryption question?

  • Thread starter Thread starter J.R
  • Start date Start date
J

J.R

The below code works if "Input" is the result of a read from a binary file.
I want Input to be a literal string variable. When this is the case,
received "Length of Data to Decrypt is Invalid" error.

Any ideas appreciated.

Thank you, John.

arrResult = UTF8.GetBytes(Input);

MemoryStream stmDecrypted = new MemoryStream();

cptTransform = tDesProvider.CreateDecryptor(arrKeyBytes, arrIVBytes);

CryptoStream stmCrypt = new CryptoStream(stmDecrypted, cptTransform,
CryptoStreamMode.Write);

stmCrypt.Write(arrResult, 0, arrResult.Length);

stmCrypt.FlushFinalBlock();


stmDecrypted.Position = 0;


stmDecrypted.Read(arrResult, 0, Convert.ToInt32(stmDecrypted.Length));

Output = UTF8.GetString(arrResult);
 
Back
Top