Pequeño programa escrito en python para codificar o decodificar un texto a base64 o de base64 a ASCII.

#!/usr/bin/env python

'''
@copyright: GPL v.3
@author: jano
@contact: borja(dot)luaces(at)gmail(dot)com
'''

import base64,sys

try:
    import psyco
    psyco.full()
except ImportError:
   print 'psyco not detected...'
   pass

if len(sys.argv) < 3:
    print 'need more arguments...'
    print 'usage: \n ./base64_encoder_decoder (-e/-d) "text"\n -e -> encode\n  //
-d -> decode\n It is very important to insert the text between ""'
else:
    try:
        var1 = sys.argv[1]
        var2 = sys.argv[2]
    except IndexError:
        pass

    if var1 == '-e':
        texto_ascii = var2
        texto_base64 = base64.b64encode(texto_ascii)
        print 'The text in ASCII code is: %s' %texto_ascii
        print 'Text coded to base64 is: %s' %texto_base64

    elif var1 == '-d':
        texto_base64 = var2
        texto_ascii = base64.b64decode(texto_base64)
        print 'The text in base64 is: %s' %texto_base64
        print 'Text decoded to ASCII is: %s' %texto_ascii