"Anthra Norell" <[EMAIL PROTECTED]> writes: > I rolled my own for relatively short sequences, like passwords. The > key is an integer. To decrypt use the negative encryption key. I > consider the encryption unbreakable, as it is indistinguishable from > a random sequence.
You're using the built-in random module which is designed to provide only statistical randomness and not cryptographic security. It should not be used for encryption. The math paper describing the function is quite clear about that. There is a lot of subtlety to this stuff and it's easy to make mistakes even if you know what you're doing. Even using well-tested block ciphers (various people mentioned DES, AES, and Blowfish modules) it's easy to make mistakes in choosing operation modes, thinking you don't need authentication when you really do, etc., etc. The book "Practical Cryptography" by Bruce Schneier and Niels Ferguson is worth looking at if you want to see what you're getting yourself into. I hate to come across as plugging my own stuff too much, but http://www.nightsong.com/phr/crypto/p3.py is designed to take care of most of the tricky issues for you while still having a very simple interface, and also be reasonably fast (much faster for large messages than any of the pure Python block cipher modules). Just use p3_encrypt(plain) to encrypt and p3_decrypt(cipher) to decrypt. The main penalty you pay is that the ciphertext is a couple dozen bytes longer than the plaintext. There are cryptographically important reasons for that; don't try to escape it without knowing exactly what's going on. -- http://mail.python.org/mailman/listinfo/python-list