Skip to content

Instantly share code, notes, and snippets.

@johnludwigm
Created January 25, 2018 22:28
Show Gist options
  • Save johnludwigm/f020b165c0d18d0e7509e78c39569c40 to your computer and use it in GitHub Desktop.
Save johnludwigm/f020b165c0d18d0e7509e78c39569c40 to your computer and use it in GitHub Desktop.
A possible way to encrypt a secret key only using base
aws_secret_access_key = "BmUejjI9Fp23FAOJoijeRAJse/fAEIfo4FAJFIwe"
#It is absolutely infeasible to find a string which hashes to something
#that even remotely resembles your aws_secret_access_key.
the_password_I_will_enter = "MySecretPassword"
#Note that the_password_I_will_enter is a string rather than a bytes object:
"""
>>> isinstance("MySecretPassword", str)
True
>>> isinstance("MySecretPassword", bytes)
False
"""
#Hence, we have to first convert it to a bytes object before computing its
#md5 hash.
"""
>>> md5(b"MySecretPassword").hexdigest()
'7315a012ecad1059a3634f8be1347846'
"""
#Now observe that "B", "m", "U" aren't even in the hash value, so you would
#have to apply another transformation in order to create them from the hash
#value.
#This would get complicated, but it is entirely feasible.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment