KITA Eng.

北海道でサーバー技術者として歩み出したひとが綴るblog。

Windowsでchecksumを調べる---FCIVを利用してみた

「ファイル チェックサム整合性検証 (FCIV) ユーティリティ」を使ってみました。 特に深い理由はありません。GIMPさんをインストールするときに徐に、ダウンロードファイルのMD5チェックサムでも一応確認しようかとふと思い立っただけです。

FCIVですが、

FCIV ユーティリティは、Microsoft Windows 2000Windows XP、および Windows Server 2003 上で実行されます。
https://support.microsoft.com/ja-jp/kb/841290

なんてあって、ドキュメントの最終更新が2011/09/10のようなので、古くからあるツールの模様。

手元のWindows10では、公式ドキュメントのインストールの項目どおりに作業すれば問題なく動きました。コマンドプロンプトからでももちろんPowrShellからでも問題ないようです。

チェックサムを計算
PS C:\Users\Kastuay\Downloads> fciv.exe .\gimp-2.8.16-setup-4.exe
//
// File Checksum Integrity Verifier version 2.05.
//
3dbad964d5fe1d2a065bc9cbea0ee1a0 .\gimp-2.8.16-setup-4.exe

md5ないし、sha1でのハッシュ値を計算できるようで、特定のディレクトリ下を再帰的に確認して、xmlで出力するなんてこともできるんだとか。

ディレクトリ下の各ファイルのチェックサムを計算して、xml形式ファイルに出力
PS C:\Users\Katsuya\Downloads> fciv.exe -r .\sumtest\ -xml sumtest.xml
//
// File Checksum Integrity Verifier version 2.05.
//
Start Time: 06/11/2016 at 12h40'36''

Error loading XML document.
Create New XML database

End Time..: 06/11/2016 at 12h40'37''


        Processed 1 directories
        Processed 2 files
Errors have been reported to fciv.err
出力したXMLファイルの内容からチェックサム結果を表示
PS C:\Users\Katsuya\Downloads> fciv.exe -list -xml .\sumtest.xml
//
// File Checksum Integrity Verifier version 2.05.
//
Listing entries in database:
----------------------------

                MD5                             Filename
-------------------------------------------------------------------------
acc0db27eed709ecb25e5369fb8cfd87 .\sumtest\FileZilla_3.13.1_win64.zip
3dbad964d5fe1d2a065bc9cbea0ee1a0 .\sumtest\gimp-2.8.16-setup-4.exe
チェックサムと一致するか確認する。
PS C:\Users\Katsuya\Downloads> fciv.exe -v -xml .\sumtest.xml
一致
PS C:\Users\Katsuya\Downloads> fciv.exe -v -xml .\sumtest.xml
//
// File Checksum Integrity Verifier version 2.05.
//
Could not create the registry key.
Starting checksums verification : 06/11/2016 at 12h54'37

All files verified successfully

End Verification : 06/11/2016 at 12h54'37
不一致

一方のZIPファイルの中身をちょっといじってみた。

PS C:\Users\Katsuya\Downloads> fciv.exe -v -xml .\sumtest.xml
//
// File Checksum Integrity Verifier version 2.05.
//
Could not create the registry key.
Starting checksums verification : 06/11/2016 at 12h55'58

List of modified files:
-----------------------
.\sumtest\FileZilla_3.13.1_win64.zip
        Hash is         : acc0db27eed709ecb25e5369fb8cfd87
        It should be    : ea4684909453db52c7d4fa3105bdcd8e

End Verification : 06/11/2016 at 12h55'58
XMLの中身

チェックサムの結果は、Base64エンコードされて格納される仕様だそうだ。なのでXMLを直接ただ見ただけだとチェックサムの値はわからない。

Base64デコードするか、FCIVの-listオプションを使ってプロンプト上で見る必要がある模様。 f:id:kacchan822:20160611125121p:plain


ユーティリティ説明資料