diff options
author | Legrandin <gooksankoo@hoiptorrow.mailexpire.com> | 2012-05-17 21:46:05 +0200 |
---|---|---|
committer | Legrandin <gooksankoo@hoiptorrow.mailexpire.com> | 2012-05-17 22:17:38 +0200 |
commit | 3a9b2da0d61d422512fb5781f2aa2eeeea5ef95d (patch) | |
tree | 1b4b89daf1a065b122dfe3e4dcf13d9099ebb6f4 /lib | |
parent | 62f2c4154c89fecbacb722efaed2af01bcecab3a (diff) | |
download | pycrypto-3a9b2da0d61d422512fb5781f2aa2eeeea5ef95d.tar.gz |
Added example for OPENPGP mode in CAST module
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Crypto/Cipher/CAST.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/Crypto/Cipher/CAST.py b/lib/Crypto/Cipher/CAST.py index 1734b53..f08dab3 100644 --- a/lib/Crypto/Cipher/CAST.py +++ b/lib/Crypto/Cipher/CAST.py @@ -37,9 +37,15 @@ As an example, encryption can be done as follows: >>> >>> key = b'Sixteen byte key' >>> iv = Random.new().read(CAST.block_size) - >>> cipher = CAST.new(key, CAST.MODE_OFB, iv) + >>> cipher = CAST.new(key, CAST.MODE_OPENPGP, iv) >>> plaintext = b'sona si latine loqueris ' - >>> msg = iv + cipher.encrypt(plaintext) + >>> msg = cipher.encrypt(plaintext) + >>> + ... + >>> eiv = msg[:CAST.block_size+2] + >>> ciphertext = msg[CAST.block_size+2:] + >>> cipher = CAST.new(key, CAST.MODE_OPENPGP, eiv) + >>> print cipher.decrypt(ciphertext) .. _CAST-128: http://en.wikipedia.org/wiki/CAST-128 .. _RFC2144: http://tools.ietf.org/html/rfc2144 |