Differences

This shows you the differences between two versions of the page.

Link to this comparison view

pythonenc [2014/10/26 01: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]]
  
pythonenc.txt ยท Last modified: 2014/10/26 01:52 (external edit)
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0