{{category Windows Command,nolink}} ファイルのハッシュ値の計算と確認 !!!FCIV (File Checksum Integrity Verifier) utility. FCIV は、マイクロソフトが提供するファイルの暗号ハッシュを計算するコマンドラインユーティリティ。 サポートされるハッシュアルゴリズムは、MD5 と SHA1 。 ハッシュ値は、コンソールに出力 もしくは、XML形式のファイルに出力される。 実行ファイルは、サポートページから Windows-KB841290-x86-ENU.exe というファイルが入手出来る。 * File Checksum Integrity Verifier ユーティリティーの入手方法およびその説明 ** http://support.microsoft.com/kb/841290/ja ** http://support.microsoft.com/kb/841290/en-us * ファイルの MD5 または sha-1 暗号化ハッシュ値を計算する方法 ** http://support.microsoft.com/kb/889768/ja //* Download the File Checksum Integrity Verifier utility package //** http://download.microsoft.com/download/c/f/4/cf454ae0-a4bb-4123-8333-a1b6737712f7/Windows-KB841290-x86-ENU.exe !!!コマンドライン // // File Checksum Integrity Verifier version 2.05. // Usage: fciv.exe [Commands] Commands: ( Default -add ) -add : Compute hash and send to output (default screen). dir options: -r : recursive. -type : ex: -type *.exe. -exc file: list of directories that should not be computed. -wp : Without full path name. ( Default store full path) -bp : specify base path to remove from full path name -list : List entries in the database. -v : Verify hashes. : Option: -bp basepath. -? -h -help : Extended Help. Options: -md5 | -sha1 | -both : Specify hashtype, default md5. -xml db : Specify database format and name. To display the MD5 hash of a file, type fciv.exe filename !!!簡単な使い方 !!ハッシュ値を求める MD5(-md5) か SHA1(-sha1) か 両方(-both) かを指定して、ファイルを指定する。 C:\>fciv -sha1 C:\Windows\System32\cmd.exe // // File Checksum Integrity Verifier version 2.05. // f5cfd4070ea7d2b40a29f21f9e29af23341c59ec c:\windows\system32\cmd.exe !!XML DB に保存し比較をする 「-xml」で保存するXMLファイル名を指定する。 C:\>fciv -sha1 C:\Windows\System32\cmd.exe -xml sha1.xml // // File Checksum Integrity Verifier version 2.05. // 「-list」オプションで XML DB の内容を表示する。指定したハッシュアルゴリズムが表示される。 C:\>fciv -list -sha1 -xml sha1.xml // // File Checksum Integrity Verifier version 2.05. // Listing entries in database: ---------------------------- SHA1 Filename ------------------------------------------------------------------------- f5cfd4070ea7d2b40a29f21f9e29af23341c59ec c:\windows\system32\cmd.exe Number of entries found: 1 「-v」オプションで XML DB の内容を比較する。 C:\>fciv -v -xml sha1.xml // // File Checksum Integrity Verifier version 2.05. // Could not create the registry key. Starting checksums verification : 09/03/2014 at 19h11'57 All files verified successfully End Verification : 09/03/2014 at 19h11'57 XML DB は以下のように保存される。 C:\>type sha1.xml c:\windows\system32\cmd.exe9c/UBw6n0rQKKfIfnimvIzQcWew= !!UNIX の md5sum, sha1sum の出力形式に似せる FCIV はそのまま出力すると先頭3行にFCIVのロゴが出力される。 ので、FORコマンドを利用し先頭3行をスキップして出力する。 for /F "skip=3 delims=" %s in ('fciv -md5 C:\temp') do @echo %s>>md5.txt