diff options
author | lloyd <[email protected]> | 2008-09-29 20:17:08 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2008-09-29 20:17:08 +0000 |
commit | 7c0319368d1948d54db514e5f72c589a397e2909 (patch) | |
tree | 2d52b6dd8715a6ea0fc21b3a66673fb38a8d4ebb /wrappers/swig/tests/block.py | |
parent | 0f2dfff90fe3882a85308d66a05803178a452023 (diff) |
Remove the misc dir:
Moved XS, Boost Python, and SWIG wrappers to new toplevel directory 'wrappers'
Moved NIST X.509 test suite into checks directory
Move the build information used by configure.pl to src/build-data
Move scripts directory to doc (for lack of a better spot)
Diffstat (limited to 'wrappers/swig/tests/block.py')
-rw-r--r-- | wrappers/swig/tests/block.py | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/wrappers/swig/tests/block.py b/wrappers/swig/tests/block.py new file mode 100644 index 000000000..593937c81 --- /dev/null +++ b/wrappers/swig/tests/block.py @@ -0,0 +1,52 @@ +#!/usr/bin/python + +import botan, base64 + +class MyCipher(botan.BlockCipher): + def __init__(self): + botan.BlockCipher.__init__(self, 16, 16, 32, 8) + def encrypt(self, val): + print "encrypt", val + return val.swapcase() + def decrypt(self, val): + print "decrypt", val + return val.swapcase() + def set_key(self, key): + print "set_key", key + def clone(self): + print "cloning" + return MyCipher() + def name(self): + print "naming" + return "MyCipher" + +cipher = botan.BlockCipher("AES-128") + +print cipher.block_size +print cipher.keylength_min +print cipher.keylength_max +print cipher.keylength_mod +print cipher.name() + +for kl in range(1, 128): + if cipher.valid_keylength(kl): + print "1", + else: + print "0", +print +key = botan.SymmetricKey(16) + +cipher.set_key(key) +ciphertext = cipher.encrypt("ABCDEFGH12345678") +print base64.b16encode(ciphertext) + +cipher2 = cipher.clone() +cipher2.set_key(key) + +plaintext = cipher2.decrypt(ciphertext) +print plaintext + +botan.get_info(cipher) + +mycipher = MyCipher() +botan.get_info(mycipher) |