functions/converters/ConvertTo-SHA256.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
function ConvertTo-SHA256 {
    Param (
        [Parameter(Mandatory = $true)]
        [string]$String
    )

    process {
        $hasher = [System.Security.Cryptography.HashAlgorithm]::Create('sha256')
        $hash = $hasher.ComputeHash([System.Text.Encoding]::UTF8.GetBytes($String))

        $hashString = [System.BitConverter]::ToString($hash)
        $hashString -replace '-', ''
    }
}