Last active
July 31, 2024 07:41
-
-
Save jokecamp/2c1a67b8f277797ecdb3 to your computer and use it in GitHub Desktop.
Powershell HMAC SHA 256 Example
This file contains 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
# Powershell HMAC SHA 256 | |
$message = 'Message' | |
$secret = 'secret' | |
$hmacsha = New-Object System.Security.Cryptography.HMACSHA256 | |
$hmacsha.key = [Text.Encoding]::ASCII.GetBytes($secret) | |
$signature = $hmacsha.ComputeHash([Text.Encoding]::ASCII.GetBytes($message)) | |
$signature = [Convert]::ToBase64String($signature) | |
echo $signature | |
# Do we get the expected signature? | |
echo ($signature -eq 'qnR8UCqJggD55PohusaBNviGoOJ67HC6Btry4qXLVZc=') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This worked perfectly. Thanks!