ハッシュ値とは?
- 知る
- 使う
ソフトの配布ページに、長い英数字の「SHA-256」が載っているけれど、何のためのもの? それが、ハッシュ値です。ファイルのハッシュ値を調べる(SHA-256) で調べられるハッシュ値の、基本をやさしく説明します。
ハッシュ値とは
ファイルの中身を、決まった計算で、決まった長さの文字列にしたものです。ファイルの「指紋」にたとえられます。
ハッシュ値の特徴
- 同じ中身なら、同じ値:何度計算しても、同じ結果になる。
- 1文字違えば、まったく別の値:わずかな違いでも、値が大きく変わる。
- 元に戻せない:値から、元のファイルは復元できない。
- 長さが決まっている:ファイルが大きくても小さくても、同じ長さ(SHA-256なら64文字)。
何に使うのか
- ダウンロードの確認:正しくダウンロードできたか。
- 改ざんの検出:途中で書き換えられていないか。
- 同じファイルかの判定:2つのファイルが、同じ内容か。
- 重複ファイルの発見:同じ値のファイルは、同じ内容。
手順(調べる)
- 「ファイルを1つ選ぶ」で、ファイルを選びます。
- 少し待つと、ハッシュ値(SHA-256)が表示されます。
- 「SHA-256をコピー」で、コピーできます。
ハッシュ値でわからないこと
- ファイルの安全性(ウイルスがないか)
- ファイルの作者や、出どころ
- ファイルが正しい内容か
ハッシュ値は、「同じかどうか」を確かめるものです。
パスワードとの関係
サービスは、パスワードをそのまま保存せず、ハッシュ値にして保存することがあります。同じ仕組みを使っています。
例
2つのバックアップファイルのハッシュ値を調べたら、同じ値だった。ファイル名は違っても、中身は同じと分かった。
つまずきやすい点
- 「暗号化」と混同する:ハッシュは、元に戻せない。暗号化は、鍵で元に戻せる。
- 値の一部だけ比べる:全部を比べないと、確実ではない。
よくある質問
ハッシュ値が同じなら、必ず同じファイルですか?
実用上、SHA-256が同じなら、同じファイルと考えて問題ありません。
まとめ
ハッシュ値は、ファイルの指紋。同じかどうかを確かめるために使います。
ファイルのハッシュ値を調べる(SHA-256)を使う(無料)あわせて使えるツール
- ZIPを開く(解凍):ZIPの中身を見て、ほしいファイルだけ取り出します。
- ファイルをZIPにまとめる:複数のファイルを、1つのZIPにまとめます。
- 安全なパスワードを作る(ランダム生成):強いランダムなパスワードを、すぐに作ります。
同じツールの、ほかの解説
What Is a Hash?
- Learn
- Use
A software download page lists a long string of letters and digits called "SHA-256". What is it for? That is a hash value. Here is a gentle explanation of the basics of the hash value that Check a File's Hash (SHA-256) can check.
What a hash is
It turns a file's contents, by a fixed calculation, into a string of fixed length. It is compared to the file's "fingerprint".
Characteristics of a hash
- Same contents, same value: the result is the same however many times it is calculated.
- One character different, a totally different value: even a slight difference changes the value greatly.
- Cannot be reversed: the original file cannot be restored from the value.
- Fixed length: the same length (64 characters for SHA-256) whether the file is large or small.
What it is used for
- Checking downloads: whether it downloaded correctly.
- Detecting tampering: whether it was rewritten on the way.
- Judging whether files are the same: whether two files have the same contents.
- Finding duplicate files: files with the same value have the same contents.
Steps (checking)
- Choose a file with "Choose one file".
- After a short wait, the hash (SHA-256) is displayed.
- Copy it with "Copy SHA-256".
What a hash cannot tell you
- The file's safety (whether it has a virus)
- The file's author or origin
- Whether the file's contents are correct
A hash is for checking "whether it is the same".
Relation to passwords
Services sometimes store passwords not as they are but as hashes. The same mechanism is used.
Example
Checking the hashes of two backup files gave the same value. Although the file names differed, the contents were the same.
Common stumbling blocks
- Confusing it with "encryption": a hash cannot be reversed. Encryption can be undone with a key.
- Comparing only part of the value: it is not certain unless you compare all of it.
Frequently asked questions
If the hashes are the same, is it certainly the same file?
In practice, if the SHA-256 is the same, it is fine to consider it the same file.
Summary
A hash is a file's fingerprint. It is used to check whether things are the same.
Use "Check a File's Hash (SHA-256)" (free)Tools that go well with this
- Open a ZIP File (Unzip): See what is inside a ZIP and extract the files you need.
- Make a ZIP File: Pack several files into one ZIP.
- Generate a Strong Random Password: Generate strong random passwords instantly.