Hi All,
There used to be a tool for encrypting data using HMAC_SHA256, which I had downloaded previously from:
https://betagallery.alteryx.com/#!app/HMAC-Encrypt--Installer-/576326f1aa690a05284b2e7b
It looks like the gallery migrated to a new home on the Alteryx Gallery, but I can't find the above macro.
There is a CReW SHA256 encription tool, which I might be able to use instead (if I can figure out exactly how HMAC_SHA256 uses the encryption key) but it's a bit of a shame because the older tool did all the work for me.
Anyone have any ideas if the older HMAC_SHA256 tool is still available anywhere? (kicking myself for not saving a copy)
Thanks!
JamieH
Solved! Go to Solution.
I know the one you're talking about, but can't find it right now. So annoying when you know there is something out there, but just can't find it. If I have it on my home computer somewhere, then I'll come back and post it.
This link has a couple links for Alteryx encryption tools either built in C or using R Tool.
This tool was built a couple years ago by @MarqueeCrew & @grossal when the HMAC Encrypt macro couldn't be found.
This was the original link, but it's not working right now: https://gallery.alteryx.com/#!app/HMAC-Encrypt--Installer-/576326f1aa690a05284b2e7b
And another link with the code in it: https://community.alteryx.com/t5/Alteryx-Designer-Desktop-Discussions/SHA256-Hash-Base64-Encoding-No...
from ayx import Alteryx
import hmac
import hashlib
def hmac_sha256(key, message):
"""Generates an HMAC SHA256 signature for the given message and key."""
# Ensure the key and message are in bytes format
if isinstance(key, str):
key = key.encode('utf-8')
if isinstance(message, str):
message = message.encode('utf-8')
return hmac.new(key, message, hashlib.sha256).hexdigest()
def verify_hmac_sha256(message, key, signature):
"""Verifies an HMAC SHA256 signature for a given message and key."""
# Compute the HMAC signature
computed_signature = hmac.new(
key.encode('utf-8'),
message.encode('utf-8'),
hashlib.sha256
).hexdigest()
# Compare the computed signature with the provided signature
return hmac.compare_digest(computed_signature, signature)
# Example usage
message = "Hello, world!"
key = "secret_key"
signature = hmac_sha256(key, message)
print(signature)
is_valid = verify_hmac_sha256(message, key, signature)
if is_valid:
print("Signature is valid.")
else:
print("Signature is not valid.")
Attached is the installer from the original https://gallery.alteryx.com/ link.
Thank you!