目錄

名稱

Digest::file - 計算檔案摘要

語法

# Poor mans "md5sum" command
use Digest::file qw(digest_file_hex);
for (@ARGV) {
    print digest_file_hex($_, "MD5"), "  $_\n";
}

說明

此模組提供 3 個便利函式來計算檔案摘要。提供以下函式

digest_file( $file, $algorithm, [$arg,...] )

此函式將計算並傳回給定檔案的位元組摘要。如果無法開啟或讀取檔案,函式將會出錯。

$algorithm 是字串,例如「MD2」、「MD5」、「SHA-1」、「SHA-512」。其他引數會傳遞給給定演算法實作的建構函式。

digest_file_hex( $file, $algorithm, [$arg,...] )

與 digest_file() 相同,但以十六進位形式傳回摘要。

digest_file_base64( $file, $algorithm, [$arg,...] )

與 digest_file() 相同,但將摘要傳回為 base64 編碼字串。

另請參閱

Digest