Skip to content

Instantly share code, notes, and snippets.

@adamjasinski
adamjasinski / base32_decode.py
Created February 12, 2022 17:34
Decodes a Base32 command-line parameter to UUID, using .NET Guid-compatible byte order
#!/usr/bin/python3
import uuid
import base64
import sys
def base32decode(s):
# NB - input should be a hex string of 26 characters
padded_bytes = f"{s}======".encode('ascii')
decoded_bytes = base64.b32decode(padded_bytes, casefold=True)
# NB - bytes_le uses .NET Guid-compatible byte order