Ejemplo n.º 1
0
def run():
    #id_secret='cff03377815197df' # 567cc1640266789c'
    id_secret = '0123456789abcdef'
    cipher = Blowfish.new(smart_str(id_secret), mode=Blowfish.MODE_ECB)

    message = '*****@*****.**'
    s = smart_str(message)
    # Pad to a multiple of 8 with leading "!"
    s = (b"!" * (8 - len(s) % 8)) + s
    print "S: " + s
    # Encrypt
    encrypted = cipher.encrypt(s)
    print "Encrypted: " + encrypted
    encoded = codecs.encode(encrypted, "hex")
    print "Encoded: " + encoded
    #print unicodify(codecs.encode(cipher.encrypt(s), 'hex'))
    print unicodify(encoded)

    security = SecurityHelper(id_secret=id_secret)
    print security.encode_guid(message)
parser.add_argument('action', metavar='ACTION', type=str,
                    default=None,
                    help='decode|encode')
parser.add_argument('value', metavar='VALUE', type=str,
                    default=None,
                    help='value to encode or decode')
populate_config_args(parser)
args = parser.parse_args()

app_properties = app_properties_from_args(args)
helper = SecurityHelper(id_secret=app_properties.get('id_secret'))

# We need the ID secret for configuring the security helper to decrypt
# galaxysession cookies.
if "id_secret" not in app_properties:
    log.warning('No ID_SECRET specified. Please set the "id_secret" in your galaxy.yml.')

id_secret = app_properties.get('id_secret', 'dangerous_default')

security_helper = SecurityHelper(id_secret=id_secret)
# And get access to the models
# Login manager to manage current_user functionality

if args.action == 'decode':
    sys.stdout.write(security_helper.decode_guid(args.value.lstrip('F')))
elif args.action == 'encode':
    sys.stdout.write(security_helper.encode_guid(args.value))
else:
    sys.stdout.write("Unknown argument")
sys.stdout.write('\n')
Ejemplo n.º 3
0
                    metavar='VALUE',
                    type=str,
                    default=None,
                    help='value to encode or decode')
populate_config_args(parser)
args = parser.parse_args()

app_properties = app_properties_from_args(args)
helper = SecurityHelper(id_secret=app_properties.get('id_secret'))

# We need the ID secret for configuring the security helper to decrypt
# galaxysession cookies.
if "id_secret" not in app_properties:
    log.warning(
        'No ID_SECRET specified. Please set the "id_secret" in your galaxy.yml.'
    )

id_secret = app_properties.get('id_secret', 'dangerous_default')

security_helper = SecurityHelper(id_secret=id_secret)
# And get access to the models
# Login manager to manage current_user functionality

if args.action == 'decode':
    sys.stdout.write(security_helper.decode_guid(args.value.lstrip('F')))
elif args.action == 'encode':
    sys.stdout.write(security_helper.encode_guid(args.value))
else:
    sys.stdout.write("Unknown argument")
sys.stdout.write('\n')