Skip to content

Instantly share code, notes, and snippets.

@lxneng
Created February 21, 2011 10:27
Show Gist options
  • Save lxneng/836903 to your computer and use it in GitHub Desktop.
Save lxneng/836903 to your computer and use it in GitHub Desktop.
>>> from pyDes import *
>>> data = 'welcome to china'
>>> k = des('DESCRYPT', CBC, '\0\0\0\0\0\0\0\0', pad=None, padmode=PAD_PKCS5)
>>> d = k.encrypt(data)
>>> print "Encrypted: %r" % d
Encrypted: '\x7f\xd0\xdc\x1b\x86Y\xe7\xf2\xcb\xd5 tR\xa9G\x8a>-\x07\xec\xb3)\xce
\xa0'
>>> print "Decrypted: %r" % k.decrypt(d)
Decrypted: 'welcome to china'
>>> assert k.decrypt(d, padmode=PAD_PKCS5) == data
>>>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment