Gabriel87 Posted July 24, 2011 Report Posted July 24, 2011 #!/usr/bin/env python#Name: b64.py#Author: s3my0nfrom base64 import b64decodefrom base64 import b64encodeimport sysdef Decode(enc_string): try: dec_string = b64decode(enc_string) except TypeError: print '\nTypeError: not a valid base64 hash' sys.exit(1) return dec_stringdef Encode(string): enc_string = b64encode(string) return enc_stringif __name__ == '__main__': opts = ('-de', '-en') if (len(sys.argv) != 3) or (sys.argv[1] not in opts): print '\nBase64 encoder/decoder' print 'Coded by RuSH4ck3R aka s3my0n' print '\nUsage: b64.py [-de, -en] [hash, string]' print '\nExample: b64.py -en mypassword' print ' b64.py -de bXlwYXNzd29yZA==' sys.exit() if sys.argv[1] == opts[0]: print '%s' % (Decode(sys.argv[2])) if sys.argv[1] == opts[1]: print '%s' % (Encode(sys.argv[2])) Quote