[PYTHON-CRYPTO] [newbie] encyption/decryption and padding

Morten Bagai mbagai at ARSLEGAL.COM
Tue Nov 29 21:04:35 CET 2005


I'm new to pycrypto. I'm trying to do something really basic, which  
is to decrypt an ASCII-HEX block of ciphertext with Blowfish using a  
simple key. Here's how i do it:

from Crypto.Cipher import Blowfish
from binascii import hexlify,unhexlify

# some ascii-hex cipher text
ciphertext =  
# not a real key
key = 'blah'

mycipher = Blowfish.new(pwd,Blowfish.MODE_ECB)
cleartext =  mycipher.decrypt(unhexlify(ciphertext))

This works fine, except in addition to the original cleartext, i also  
get the padding as a result of the "decrypt" method call. Is this  
normal? If so, what's the standard way to get rid of the padding?  
Also, when encrypting with a symmetric algorithm like Blowfish, are  
there any convenience functions in the toolkit for applying padding,  
say PKCS#5, automatically?


-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 186 bytes
Desc: This is a digitally signed message part
URL: <http://mail.python.org/pipermail/python-crypto/attachments/20051129/58fc2deb/attachment.pgp>

More information about the python-crypto mailing list