Base64文字列比較
2つのBase64文字列を並べて比較。デコードされた内容が一致するか確認し、相違点をハイライトし、Base64エンコードデータを比較します。100%クライアントサイド。
100%クライアントサイド — データがデバイスから離れることはありません
Enter two Base64 strings above and click Compare
コード例
プロジェクトにすぐに使えるコードスニペットです。
Python
import base64
def compare_base64(a: str, b: str) -> dict:
result = {
"same_string": a == b,
"same_content": False,
"differences": []
}
try:
decoded_a = base64.b64decode(a)
decoded_b = base64.b64decode(b)
result["same_content"] = decoded_a == decoded_b
# Find character-level differences
for i, (ca, cb) in enumerate(zip(a, b)):
if ca != cb:
result["differences"].append(
f"Position {i}: '{ca}' vs '{cb}'"
)
if len(a) != len(b):
result["differences"].append(
f"Length mismatch: {len(a)} vs {len(b)}"
)
except Exception as e:
result["error"] = str(e)
return result
print(compare_base64("SGVsbG8=", "SGVsbG8="))
# {'same_string': True, 'same_content': True, 'differences': []}よくある質問
以下を検索するか、よくある質問をご覧ください。
このツールは両方の文字列をデコードし、生のバイナリコンテンツを比較します。これにより、テキスト形式が異なっていても、まったく同じ基盤データを表しているかどうかを判断できます。
異なるエンコーダーが改行(MIME形式)、パディング、または文字セットを異なる方法で処理する可能性があります。当社の比較ツールは正確な文字の不一致をハイライト表示します。