Hi, everyone!
In a previous post, I built a function on how to get an MD5 hash from a file stored in memory. I had a particular need this holiday season to compute a hash of a text input string, so I thought I would share my solution with you:
Function Get-HashFromString($String)
{
$md5hash = New-Object -TypeName System.Security.Cryptography.MD5CryptoServiceProvider
$utf = New-Object -TypeName System.Text.UTF8Encoding
$value = [System.BitConverter]::ToString($md5hash.ComputeHash($utf.GetBytes($String)))
$value = $value.Replace("-", "")
Return $value
}
Once this function is loaded (interactively, dot sourced, part of your $PROFILE, whatever makes your world go ’round), you can simply run Get-HashFromString <string value> and off you go! A new hash!

