Skip to content

Instantly share code, notes, and snippets.

@karb0f0s
Forked from dalton-cole/PS MD5 from text
Created March 8, 2018 09:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save karb0f0s/8ebcebf71b067fa2260faa575397f2a4 to your computer and use it in GitHub Desktop.
Save karb0f0s/8ebcebf71b067fa2260faa575397f2a4 to your computer and use it in GitHub Desktop.
PowerShell text to MD5 hash
#converts string to MD5 hash in hyphenated and uppercase format
$someString = "test"
$md5 = new-object -TypeName System.Security.Cryptography.MD5CryptoServiceProvider
$utf8 = new-object -TypeName System.Text.UTF8Encoding
$hash = [System.BitConverter]::ToString($md5.ComputeHash($utf8.GetBytes($someString)))
#to remove hyphens and downcase letters add:
$hash = $hash.ToLower() -replace '-', ''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment