Click here to Skip to main content
15,891,248 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
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:
C#
private byte[] IV = { 0, 0, 0, 0, 0, 0, 0, 0 };

public override byte[] Encrypt(byte[] plainText, byte[] key)
{
//// create the crypto service provider
TripleDESCryptoServiceProvider des3 = new TripleDESCryptoServiceProvider();
des3.Mode = CipherMode.CBC;

des3.Padding = PaddingMode.None;

// create the key
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
Posted
Updated 15-Aug-10 20:09pm
v2
Comments
Peter_in_2780 16-Aug-10 4:04am    
If you didn't get an answer in the C# forum, why do you think you'll get one here?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900