Hi all,
I'm new to this forum, I will be very happy if some one can help me with this issue.
I am trying to Encrypt / Decrypt a text as the following
The text is in the format VISA-0 is
041242abcdef6789
The master key is
0123456789abcdef
After encrypting with Triple DES I obtain the following string.
Y9cIS8NUsry7ddNV9cSY7w==
I need to obtain an encrypted string in VISA-0 Format, that is 16 bytes.
I tested this data in a simulator and the outcome should be:
7ea13f5c64c7363b
The same in Base64 is
fqE/XGTHNjs=
The code I am using for encryption is:
private byte[] IV = { 0, 0, 0, 0, 0, 0, 0, 0 };
public override byte[] Encrypt(byte[] plainText, byte[] key)
{
TripleDESCryptoServiceProvider des3 = new TripleDESCryptoServiceProvider();
des3.Mode = CipherMode.CBC;
des3.Padding = PaddingMode.None;
PasswordDeriveBytes passwordDeriveBytes = new PasswordDeriveBytes(Convert.ToBase64String(key), new byte[0]);
des3.Key = passwordDeriveBytes.CryptDeriveKey("TripleDES", "SHA1", 0, this.IV);
des3.IV = this.IV;
MemoryStream memoryStream = new MemoryStream();
CryptoStream cryptoStream = new CryptoStream(memoryStream, des3.CreateEncryptor(), CryptoStreamMode.Write);
cryptoStream.Write(plainText, 0, plainText.Length);
cryptoStream.FlushFinalBlock();
return memoryStream.ToArray();
}
How do I obtain an encrypted string in VISA-0 Format, that is 16 bytes, using TripleDes and a 16 byte masterkey like:
0123456789abcdef
Thanks in advance for your help
Maria