Ejemplo n.º 1
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()
Ejemplo n.º 2
0
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()
Ejemplo n.º 3
0
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
Ejemplo n.º 4
0
def test(cipher):
    print
    print cipher
    print "Testing", cipher.name()
    print cipher.block_size
    print cipher.keylength_min, cipher.keylength_max, cipher.keylength_mod
    for i in range(1, 64):
        if cipher.valid_keylength(i):
            print "1",
        else:
            print "0",
    print
    cipher.set_key(botan.SymmetricKey(16))
    ciphertext = cipher.encrypt("aBcDeFgH" * (cipher.block_size / 8))
    print repr(ciphertext)
    print cipher.decrypt(ciphertext)
Ejemplo n.º 5
0
#!/usr/bin/python

import botan, base64

cipher = botan.StreamCipher("ARC4")

print cipher.name

key = botan.SymmetricKey(16)

cipher.set_key(key)
ciphertext = cipher.crypt("hi chappy")

cipher.set_key(key)
plaintext = cipher.crypt(ciphertext)

print plaintext
Ejemplo n.º 6
0
#!/usr/bin/python

import botan, base64

mac = botan.MAC("HMAC(SHA-512)")

print mac.name
print mac.output_length

mac.set_key(botan.SymmetricKey("abcd"))
mac.update("hi chappy")
print base64.b16encode(mac.final())