I have a file hashed to a standard md5 Hash
Correction: OpenSSL Hashes are HEXDECIMAL representations.
MD5 Hash: 57ED2E029BF9CA39383D2A671EF4FB50
I have a program that requires a byte encoding base64 md5 hash.
MD5 BASE64 byte: 8se7isyX+S6Yei1Ah9AhsQ==
How do you use pythons 'binascii' b2a methods to convert the standard MD5 hash to a Base64?
The below is wrong.
import binascii
bin = binascii.a2b_uu('57ED2E029BF9CA39383D2A671EF4FB50')
base = binascii.b2a_base64(bin)
Output +> 'QUlZTlYUmikRYUjRXkQjWQkiiSkmkhZmVjhZkWTAAAAA\n'
TL;DR:
I need to take hexstring, convert it to binary, and then base64 the binary.. what's the python way?
Reference:
int('57ED2E029BF9CA39383D2A671EF4FB50', base=16)
. – Nobiebinascii.a2b_uu
rather thanbinascii.a2b_hex
? The former gives an error about "Trailing Garbage" when I try it with your example hex string, and it's wrong anyway (Uuencode is not the same thing as hex encoding). When I properly decode your hex string and re-encode it to base64, I getb'V+0uApv5yjk4PSpnHvT7UA==\n'
. – Pleiades