This shows you the differences between two versions of the page.
— |
pythonenc [2014/10/25 21:52] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ==== Decrypt using python and openssl ==== | ||
+ | <code> | ||
+ | #!/usr/bin/python | ||
+ | |||
+ | import os | ||
+ | import getpass | ||
+ | import commands | ||
+ | |||
+ | user = passwd = 0 | ||
+ | |||
+ | SECRETFILE = os.environ.get('HOME') + '/.secret' | ||
+ | |||
+ | (status,response) = commands.getstatusoutput('which openssl') | ||
+ | |||
+ | if (status == 0): | ||
+ | print 'openssl ' + response | ||
+ | else: | ||
+ | print 'openssl not found' | ||
+ | exit -1 | ||
+ | |||
+ | user = getpass.getuser() | ||
+ | fh = open(SECRETFILE, 'r') | ||
+ | passwd = fh.read() | ||
+ | fh.close | ||
+ | |||
+ | print user | ||
+ | print passwd | ||
+ | |||
+ | cmd = response + ' enc -base64 -d -in ' + SECRETFILE | ||
+ | print cmd | ||
+ | (status,response) = commands.getstatusoutput(cmd) | ||
+ | print status | ||
+ | print response | ||
+ | </code> | ||
+ | ---- | ||
+ | * [[pythoninfo|Back to Python]] | ||