Base64エンコードまたはデコード結果:
コピー
Base64で文字列をエンコードする:
import base64
# 元の文字列
original_string = "@https://base64.golong.uk/"
# 文字列をエンコード
encoded_bytes = base64.b64encode(original_string.encode("utf-8"))
encoded_string = encoded_bytes.decode("utf-8")
print(encoded_string)
Base64デコードはエンコードの逆過程で、Base64エンコードされた文字列を元のバイナリ形式に変換します。
Pythonデコード例:
Base64文字列をデコードする:
import base64
# Base64エンコードされた文字列
encoded_string = "QGh0dHBzOi8vYmFzZTY0LmdvbG9uZy51ay8="
# 文字列をデコード
decoded_bytes = base64.b64decode(encoded_string)
decoded_string = decoded_bytes.decode("utf-8")
print(decoded_string)