Last active
November 15, 2017 14:43
-
-
Save tsmolka/60c0ed9d79dad5dbfb4d2dcff64eb0bf to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| Function Get-StringHash { | |
| Param ( | |
| [Parameter(ValueFromPipeline)][String[]]$String, | |
| [ValidateSet('MD5','RIPEMD160','SHA1','SHA256','SHA384','SHA512')]$HashName = 'SHA256' | |
| ) | |
| Process { | |
| $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() | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment