Functions/Data/Get-StringHash.ps1
function Get-StringHash { [CmdletBinding()] Param ( # Hashing Algorithm to use [Parameter(Mandatory=$false)] [ValidateSet("MD5","SHA1","SHA256","SHA384","SHA512")] $HashAlg = "MD5", # InputString to Hash [Parameter(Mandatory=$true)] [string] $String ) Begin {$StringBuilder = New-Object System.Text.StringBuilder} Process {[System.Security.Cryptography.HashAlgorithm]::Create($HashAlg).ComputeHash([System.Text.Encoding]::UTF8.GetBytes($String))|%{[Void]$StringBuilder.Append($_.ToString("x2"))}} End {$StringBuilder.ToString()} } |