Encoder/Decoder Base32
Mengkodekan dan mendekodekan teks menggunakan Base32.
Pertanyaan yang Sering Diajukan
Implementasi Kode
import base64
def base32_encode(text: str) -> str:
"""Encode a string to Base32."""
encoded_bytes = base64.b32encode(text.encode("utf-8"))
return encoded_bytes.decode("ascii")
def base32_decode(encoded: str) -> str:
"""Decode a Base32 string back to text."""
decoded_bytes = base64.b32decode(encoded.upper())
return decoded_bytes.decode("utf-8")
# Example usage
original = "Hello, World!"
encoded = base32_encode(original)
print(encoded) # JBSWY3DPEB3W64TMMQQQ====
decoded = base32_decode(encoded)
print(decoded) # Hello, World!
Comments & Feedback
Comments are powered by Giscus. Sign in with GitHub to leave a comment.