aboutsummaryrefslogtreecommitdiffstats
path: root/misc/python/test.py
blob: e2f1e61fab1ba3d6bf77c276447afea1ffd821d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/python

import sys, botan

def encrypt(input):
    pipe = botan.Pipe(botan.Filter("ARC4",
                                   key = botan.SymmetricKey("AABB")),
                      botan.Filter("Hex_Encoder"))

    pipe.start_msg()
    pipe.write(input)
    pipe.end_msg()

    return pipe.read_all()

def decrypt(input):
    pipe = botan.Pipe(botan.Filter("Hex_Decoder"),
                      botan.Filter("ARC4",
                                   key = botan.SymmetricKey("AABB")))

    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())