Skip to content

Instantly share code, notes, and snippets.

@Hwatwasthat
Created February 21, 2018 15:13
Show Gist options
  • Save Hwatwasthat/26e470be690266f77351c92ea7699f3c to your computer and use it in GitHub Desktop.
Save Hwatwasthat/26e470be690266f77351c92ea7699f3c to your computer and use it in GitHub Desktop.
Hex to base64 created by Hwatwasthat - https://repl.it/@Hwatwasthat/Hex-to-base64
import base64
b = '49276d206b696c6c696e6720796f757220627261696e206c696b65206120706f69736f6e6f7573206d757368726f6f6d'
def hex_to_base64(input):
# convert hex to bytearray
result = bytearray.fromhex(input)
# convert bytearray to base64
a = base64.b64encode(result)
# strip out parts at either end of a, the b' and ' symbology
a = str(a).strip("'b'")
return a
print (hex_to_base64(b))
import base64
def hex_to_base64(input):
result = bytearray.fromhex(input)
result = base64.b64encode(result)
result = str(result).strip("'b'")
return result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment