ランダムなパスワードの生成(1)
Codezineでhttp://codezine.jp/a/article.aspx?aid=238という記事が紹介されています。
Monadに移植してみました。
GUIDを使った手っ取り早いランダムなパスワードの生成
function GetRandomPasswordUsingGUID { PARAM([int]$length) #Get the GUID $guid = [System.Guid]::NewGuid().ToString() #Remove the hyphens $guid = $guid.replace("-",[String]::Empty) #Make sure length is valid if ($length -lt 0 -OR $length -gt $guid.length ) { throw "Length must be between 1 and " + $guid.length } #Return the first length bytes return $guid.substring(0, $length) }
利用サンプル
MSH C:\> GetRandomPasswordUsingGUID 10 96055361f3 MSH C:\> GetRandomPasswordUsingGUID 30 8dada0c027884eb3b34da049e8a75c