Skip to content

Instantly share code, notes, and snippets.

@jokecamp
Last active July 31, 2024 07:41
Show Gist options
  • Save jokecamp/2c1a67b8f277797ecdb3 to your computer and use it in GitHub Desktop.
Save jokecamp/2c1a67b8f277797ecdb3 to your computer and use it in GitHub Desktop.
Powershell HMAC SHA 256 Example
# 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=')
@phm200
Copy link

phm200 commented Mar 26, 2019

This worked perfectly. Thanks!

@c016smith
Copy link

Thanks!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment