Created
August 24, 2012 04:30
-
-
Save nakaji/3445423 to your computer and use it in GitHub Desktop.
MD5チェックサムを取得する
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 指定されたディレクトリ配下のファイルに対して、MD5チェックサムを取得する | |
# | |
# 下記ブログを参考に作成 | |
# PowerShell でハッシュ値を計算する(http://blogs.gine.jp/taka/archives/1369) | |
param($path) | |
function GetMD5{ | |
param($fileName) | |
$stream = New-Object IO.StreamReader $fileName | |
# MD5ハッシュ値を計算する | |
$md5 = [System.Security.Cryptography.MD5]::Create() | |
$hash = $md5.ComputeHash($stream.BaseStream); | |
$result = [System.BitConverter]::ToString($hash).Replace("-","").ToLower() | |
$result | |
} | |
Get-ChildItem $path | ?{ !$_.PSIsContainer } | | |
%{ | |
echo ($_.Name + "`t" + (GetMD5 $_.FullName)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment