From 3a9b2da0d61d422512fb5781f2aa2eeeea5ef95d Mon Sep 17 00:00:00 2001 From: Legrandin Date: Thu, 17 May 2012 21:46:05 +0200 Subject: Added example for OPENPGP mode in CAST module --- lib/Crypto/Cipher/CAST.py | 10 ++++++++-- 1 file 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 -- cgit v1.2.1