Encrypting a short string?

marek.rocki at wp.pl marek.rocki at wp.pl
Mon Feb 11 21:07:52 CET 2008

erikcw napisal(a):
> Hi,
> I'm trying to devise a scheme to encrypt/obfuscate a short string that
> basically contains the user's username and record number from the
> database.  I'm using this encrypted string to identify emails from a
> user. (the string will be in the subject line of the email).
> I'm trying to figure out which approach I should use to encrypt the
> data.  The string will be less than 20 characters long, and I'd like
> the encrypted version to be about the same size.
> I tried DES in the Crypto module, but the cipher text was to long to
> be usable in this case.
> Any suggestions?
> Thanks!

How about:
>>> hashlib.sha256("john.smith at example.com|2937267834").hexdigest()[:20]


More information about the Python-list mailing list