summaryrefslogtreecommitdiffstats
path: root/botan/wrappers/swig/doit.py
blob: a84623e871f083323a264a8de00aec5fa45bccfa (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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/python2

import botan

def hash_it(hash, input):
    f1 = botan.Filter("MD5")
    f2 = botan.Filter("Hex_Encoder")
    pipe = botan.Pipe(f1, f2)

    pipe.start_msg()
    pipe.write_string(input)
    pipe.end_msg()

    print pipe.remaining()

    out = pipe.read(0)




def main:
    init = botan.LibraryInitializer

    print hash_it("MD5", "foo")


    key1 = botan.SymmetricKey("ABCD")
    print key1.as_string()
    key2 = botan.SymmetricKey(16)
    print key2.as_string()

    iv1 = botan.InitializationVector(8)
    print iv1.as_string()


    f3 = pipe.read(pipe.remaining())

    size = pipe.remaining()
    out = botan.byte_array(size)
    pipe.read(out.cast,size)

    for i in range (0,size):
        print "%02X" % out[i]

    print pipe.read_all_as_string()

if __name__ == "__main__":
    sys.exit(main())