-
-
Save jimbrig/28e45812acfb1ddefdd2bd883c6733f0 to your computer and use it in GitHub Desktop.
PowerShell example showing outputs generated for a simple SHA-256 hash. No salting or other security mechanisms included.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$inputString = "Password123" | |
$sha256 = [System.Security.Cryptography.SHA256]::Create() | |
$bytes = [System.Text.Encoding]::UTF8.GetBytes($inputString) | |
$hashBytes = $sha256.ComputeHash($bytes) | |
$base64String = [System.Convert]::ToBase64String($hashBytes) | |
$binaryString = [System.Text.StringBuilder]::new() | |
foreach ($byte in $hashBytes) { | |
$binaryString.Append([Convert]::ToString($byte, 2).PadLeft(8, '0')) | |
} | |
Write-Output "`nHash of $inputString in 256 bit binary: $binaryString" | |
Write-Output "`nHash of $inputString in base64: $base64String" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment