[PYTHON-CRYPTO] [newbie] encyption/decryption and padding
Morten Bagai
mbagai at ARSLEGAL.COM
Tue Nov 29 21:04:35 CET 2005
Hi,
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 =
'AE930CE7794D7EFE80D30D0EC79243F99DB7C3FC5D19048D86724EA945FD8E47'
# 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?
Thanks,
Morten
-------------- 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