SHA-256 ハッシュを計算する方法
テキストやバイナリデータの SHA-256 ハッシュを計算し、その特性を理解します。
问题
入力の 1 ビットでも変われば完全に変わる、固定長のデータのフィンガープリントが必要です。
前提条件
- ハッシュ関数の基礎理解
- 16 進出力への習熟
ステップ
-
1. Prepare the input data
Determine whether your input is text or binary. For text, decide on the character encoding (UTF-8 is standard). The hash is computed over the raw bytes, so the encoding affects the result.
入力Hello, World!输出UTF-8 bytes -
2. Compute the SHA-256 digest
Feed the bytes into the SHA-256 algorithm. It processes data in 512-bit blocks and produces a 256-bit (32-byte) digest. The output is typically shown as 64 hex characters. The same input always produces the same output.
入力Hello, World!输出dffd6021bb2d5b0af876906ab0379ce8e0270918d77705e3b3568a943c7d3b0b -
3. Verify the properties
Confirm the output is 64 hex characters. Change one character of the input and re-hash; the output should change completely (avalanche effect). This sensitivity makes SHA-256 suitable for integrity verification.
入力Hello, World!!输出completely different hash
期待される結果
入力データを一意に識別する、64 文字の 16 進数 SHA-256 ダイジェスト。
よくあるエラー
- Different hash for the same text on different systems
- The character encoding differs. Ensure both systems use UTF-8. A BOM or trailing newline also changes the hash.
- Hash is not 64 characters
- You may be using a different algorithm (SHA-1 produces 40 chars, MD5 produces 32). Confirm SHA-256 is selected.
トラブルシューティング指引
- If the hash differs from an expected value, check for trailing whitespace or newlines in the input.
- For large files, use a streaming hash to avoid loading the entire file into memory.
セキュリティ上の制限
- SHA-256 is collision-resistant: finding two inputs with the same hash is computationally infeasible. It is not a password hashing function; use bcrypt or scrypt for passwords.
関連ツール
ハッシュ計算ツール
Compute MD5, SHA-1, SHA-256, or SHA-512 hashes with hex or Base64 output。無料、プライベート、100%クライアントサイド。 ツール
SHA-3 / Keccak ハッシュ計算
Compute SHA-3 (224/256/384/512) and Keccak-256 hashes。無料、プライベート、100%クライアントサイド。 ツール
ハッシュ比較ツール
Compare MD5, SHA-1, SHA-256, SHA-384, SHA-512 of the same input。無料、プライベート、100%クライアントサイド。 ツール