Skip to content

Instantly share code, notes, and snippets.

@peterVG
Last active October 4, 2020 15:08
Show Gist options
  • Save peterVG/49f5033e332e560d3384f580cc6ae39e to your computer and use it in GitHub Desktop.
Save peterVG/49f5033e332e560d3384f580cc6ae39e to your computer and use it in GitHub Desktop.
Attempt to decode Md5 hashes in base64 format
import base64
sample_string_bytes = base64.b64decode("KFukvivpCM5QXl5SqKe41g==")
print(f"Bytes: {sample_string_bytes}")
try:
sample_string = sample_string_bytes.decode("utf-8")
print(f"Decoded string: {sample_string}")
except Exception as e:
print(e)
try:
sample_string = sample_string_bytes.decode("ascii")
print(f"Decoded string: {sample_string}")
except Exception as e:
print(e)
try:
sample_string = sample_string_bytes.decode("utf-16")
print(f"Decoded string: {sample_string}")
except Exception as e:
print(e)
try:
sample_string = sample_string_bytes.decode("utf-32")
print(f"Decoded string: {sample_string}")
except Exception as e:
print(e)
(venv) peter@Peters-MacBook-Air slingshot % python scripts/decode.py
Bytes: b'([\xa4\xbe+\xe9\x08\xceP^^R\xa8\xa7\xb8\xd6'
'utf-8' codec can't decode byte 0xa4 in position 2: invalid start byte
'ascii' codec can't decode byte 0xa4 in position 2: ordinal not in range(128)
Decoded string: 嬨뺤츈幐剞Ꞩ횸
'utf-32-le' codec can't decode bytes in position 0-3: code point not in range(0x110000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment