diff options
Diffstat (limited to 'misc/swig/tests/encrypt.py')
-rw-r--r-- | misc/swig/tests/encrypt.py | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/misc/swig/tests/encrypt.py b/misc/swig/tests/encrypt.py new file mode 100644 index 000000000..9896777d4 --- /dev/null +++ b/misc/swig/tests/encrypt.py @@ -0,0 +1,37 @@ +#!/usr/bin/python + +import sys, botan + +def encrypt(input): + cipher_key = botan.SymmetricKey("AABB") + print cipher_key.length + cipher_key = botan.SymmetricKey("AABBCCDD") + print cipher_key.length + + cipher = botan.Filter("ARC4", key = cipher_key) + + pipe = botan.Pipe(cipher, botan.Filter("Hex_Encoder")) + + pipe.start_msg() + pipe.write(input) + pipe.end_msg() + + str = pipe.read_all() + print str + return str + +def decrypt(input): + pipe = botan.Pipe(botan.Filter("Hex_Decoder"), + botan.Filter("ARC4", + key = botan.SymmetricKey("AABBCCDD"))) + + pipe.process_msg(input) + return pipe.read_all() + +def main(): + ciphertext = encrypt("hi chappy") + print ciphertext + print decrypt(ciphertext) + +if __name__ == "__main__": + sys.exit(main()) |