Python Translation of C# DES Encryption
andreasp+python at qbcon.com
Fri May 12 05:00:23 EDT 2006
I'm trying to implement a Python equivalent of a C# method that encrypts
My Python attempt is in the attached file, but does not return the same
value as the C# method (see below).
The C# method:
public static string Encrypt(string decrypted)
byte data = System.Text.ASCIIEncoding.ASCII.GetBytes(decrypted);
byte rgbKey = System.Text.ASCIIEncoding.ASCII.GetBytes("12345678");
byte rgbIV = System.Text.ASCIIEncoding.ASCII.GetBytes("87654321");
MemoryStream memoryStream = new MemoryStream(1024);
DESCryptoServiceProvider desCryptoServiceProvider = new
CryptoStream cryptoStream = new CryptoStream(memoryStream,
cryptoStream.Write(data, 0, data.Length);
byte result = new byte[(int)memoryStream.Position];
memoryStream.Position = 0;
memoryStream.Read(result, 0, result.Length);
This e-mail contains official information from Quality Business Consultants (Pty) Ltd and is intended for use by the addressee only.
Important notice: Important restrictions, qualifications and disclaimers ("the Disclaimer") apply to this email.
To read this click on the following address: http://www.qbcon.com/disclaimer
The Disclaimer forms part of the content of this email in terms of section 11 of the Electronic Communications and Transactions Act, 25 of 2002. If you are unable to access the Disclaimer, send a blank e-mail to disclaimer at qbcon.com and we will send you a copy of the Disclaimer.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
More information about the Python-list