Upcoming Improvements to the Python Bindings
The Python bindings for botan are being substantially reworked and expanded in the next development release, and will soon become an officially supported feature.
A quick taste of some of the current interfaces follows after the break.
#!/usr/bin/python
import botan
import sys
def encrypt(input, passphrase):
rng = botan.RandomNumberGenerator()
# Use as both EAX IV and PBKDF2 salt
salt = rng.gen_random(10)
iterations = 10000
output_size = 16
key = botan.pbkdf2(passphrase, salt, iterations, output_size, "SHA-1")
encryptor = botan.Cipher("AES-128/EAX", "encrypt", key)
ciphertext = encryptor.cipher(input, salt)
return (ciphertext, salt)
def decrypt(input, salt, passphrase):
iterations = 10000
output_size = 16
key = botan.pbkdf2(passphrase, salt, iterations, output_size, "SHA-1")
decryptor = botan.Cipher("AES-128/EAX", "decrypt", key)
return decryptor.cipher(input, salt)
def main(args = None):
if args is None:
args = sys.argv
passphrase = args[1]
input = ''.join(open(args[2]).readlines())
(ciphertext, salt) = encrypt(input, passphrase)
print decrypt(ciphertext, salt, passphrase)
if __name__ == '__main__':
sys.exit(main())
The next development release, 1.9.1, will feature a wide variety of useful functions exported with the Python bindings, including RSA, basic crypto algorithms like hashing and encryption, PBKDF2, and botan's CryptoBox all-in-one message encryption feature. Documentation is currently sparse, but will be written as time permits and as interfaces begin to stabilize.
Posted 2009/10/13 in devnotes; no comments
< Blue Midnight Wish in Botan | 1.9.1: Blue Midnight Wish, Skein 1.2, improved Python wrappers, and more >