Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <##
- Source : https://community.idera.com/database-tools/powershell/powertips/b/tips/posts/generating-md5-hashes-from-text
- Usage : Get-StringHash "Hello World!"
- ##>
- Function Get-StringHash
- {
- param
- (
- [String] $String,
- $HashName = "MD5"
- )
- $bytes = [System.Text.Encoding]::UTF8.GetBytes($String)
- $algorithm = [System.Security.Cryptography.HashAlgorithm]::Create('MD5')
- $StringBuilder = New-Object System.Text.StringBuilder
- $algorithm.ComputeHash($bytes) |
- ForEach-Object {
- $null = $StringBuilder.Append($_.ToString("x2"))
- }
- $StringBuilder.ToString()
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement