summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLegrandin <gooksankoo@hoiptorrow.mailexpire.com>2012-05-17 21:46:05 +0200
committerLegrandin <gooksankoo@hoiptorrow.mailexpire.com>2012-05-17 22:17:38 +0200
commit3a9b2da0d61d422512fb5781f2aa2eeeea5ef95d (patch)
tree1b4b89daf1a065b122dfe3e4dcf13d9099ebb6f4
parent62f2c4154c89fecbacb722efaed2af01bcecab3a (diff)
downloadpycrypto-3a9b2da0d61d422512fb5781f2aa2eeeea5ef95d.tar.gz
Added example for OPENPGP mode in CAST module
-rw-r--r--lib/Crypto/Cipher/CAST.py10
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