src/Functions.ps1
#http://jongurgul.com/blog/get-stringhash-get-filehash/ function Get-StringHash([String] $String, $HashName = "SHA1") { $StringBuilder = New-Object System.Text.StringBuilder [System.Security.Cryptography.HashAlgorithm]::Create($HashName).ComputeHash([System.Text.Encoding]::UTF8.GetBytes($String))| % { [Void]$StringBuilder.Append($_.ToString("x2")) } $StringBuilder.ToString() } function Get-RandomCharacters($length, $characters) { $random = 1..$length | ForEach-Object { Get-Random -Maximum $characters.length } $private:ofs = "" return [String]$characters[$random] } |