Hash Data with SHA-256 in Larzscript
Compute a real SHA-256 hash and an HMAC-SHA256 message authentication code.
A real FIPS 180-4 implementation in pure Larzscript, no OS crypto library - the same code that backs larzscript update's own release-integrity check.
larzscript pkg install crypto
Code
import "crypto" as crypto
print(crypto.sha256("hello larzscript"))
print(crypto.hmac("secret-key", "message to authenticate"))Output
70a4348463191aad8ef5fc3292c882ca970b4276cb6fffaa76d7bc29395b24f7 79774090145c3f263969df659b5706baa1d03045d3f55002cf17da54e788fc22
Related
larzcryptReal SHA-256 + HMAC-SHA256, pure Larzscript→Make an HTTP GET Request in LarzscriptFetch a URL and read its status code and body - or parse a JSON API response directly.→Sign and Verify a Webhook Payload in LarzscriptSign an outgoing webhook payload with HMAC-SHA256, and verify an incoming one - the same shape real payment/webhook providers use.→Generate a UUID in LarzscriptGenerate random (v4) and time-sortable (v7, ULID, nanoid) unique identifiers.→