Boston Linux & Unix (BLU) Home | Calendar | Mail Lists | List Archives | Desktop SIG | Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings
Linux Cafe | Meeting Notes | Blog | Linux Links | Bling | About BLU

BLU Discuss list archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Looking for a Triple DES implementation



Derek Atkins wrote:
> Have you tried OpenSSL?

Huh?  Please explain.

> Also, what MODE are you using?  CFB?  CBC?

ECB

> What are you doing about the Initialization Vector?
You mean the key?  Yes, I know the phrase he's using as a key, and am
using the same thing.

> There are lots of reasons that two encryptions of the same plaintext
> wont result in the same ciphertext.  The question is whether the
> ciphertext can be converted back to the correct plaintext.

In this case, the question is can I generate the same exact output as
him, because the program that reads it expects what his program is
putting out.

I took a closer look at his program, and he's converting the output to
Base64, which explains why his output is printable characters.  He
didn't tell me that.  He's also treating the input as UTF8, but I don't
know if that matters when the input is straigh old typewriter characters.

This is the guts of his C# program:
public static string EncryptKey(string inputString, string encryptionKey)
       {
           //Used encrypt/decrypt examples from
http://www.codeproject.com/useritems/Cryptography.asp

           byte[] keyArray;
           byte[] toEncryptArray = UTF8Encoding.UTF8.GetBytes(inputString);

           keyArray = UTF8Encoding.UTF8.GetBytes(securityKey);

           TripleDESCryptoServiceProvider tdes = new
TripleDESCryptoServiceProvider();
           tdes.Key = keyArray;
           tdes.Mode = CipherMode.ECB;
           tdes.Padding = PaddingMode.PKCS7;

           ICryptoTransform cTransform = tdes.CreateEncryptor();
           byte[] resultArray =
cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length);
           tdes.Clear();
           return Convert.ToBase64String(resultArray, 0,
resultArray.Length);
       }

Thanks.





-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.







BLU is a member of BostonUserGroups
BLU is a member of BostonUserGroups
We also thank MIT for the use of their facilities.

Valid HTML 4.01! Valid CSS!



Boston Linux & Unix / webmaster@blu.org