blob: 1968b40e15ecd2278880ce9858693dee276bec2a (
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
|
#!/usr/bin/python
import sys
import botan
def main(args = None):
if args is None:
args = sys.argv
if len(args) != 3:
raise Exception("Bad usage")
password = args[1]
input = ''.join(open(args[2]).readlines())
rng = botan.RandomNumberGenerator()
ciphertext = botan.cryptobox_encrypt(input, password, rng)
print ciphertext
plaintext = ''
try:
plaintext = botan.cryptobox_decrypt(ciphertext, password + 'FAIL')
except Exception, e:
print "Oops -- ", e
plaintext = botan.cryptobox_decrypt(ciphertext, password)
print plaintext
if __name__ == '__main__':
sys.exit(main())
|