NAME
std/digest/sha - SHA digests for BinaryString values.
SYNOPSIS
from std/digest/sha import *;
let payload := to_binary( "hello" );
let key := to_binary( "shared-secret" );
let hex256 := sha256_hex(payload);
let raw512 := sha512(payload);
let auth := hmac_sha256_hex(payload, key);
IMPLEMENTATION SUPPORT
This module is supported by all implementations of ZuzuScript.
DESCRIPTION
This module provides SHA digest and HMAC helpers.
EXPORTS
Functions
For each of sha1, sha224, sha256, sha384, and sha512, this module exports three function forms:
NAME(BinaryString value)Parameters:
valueis binary input data. Returns:BinaryString. Returns the raw digest.NAME_hex(BinaryString value)Parameters:
valueis binary input data. Returns:String. Returns lowercase hexadecimal text.NAME_b64(BinaryString value)Parameters:
valueis binary input data. Returns:String. Returns Base64 text without trailing=padding.
HMAC Functions
For each of hmac_sha1, hmac_sha224, hmac_sha256, hmac_sha384, and hmac_sha512, this module exports:
NAME(BinaryString value, BinaryString key)Parameters:
valueis binary input data andkeyis the HMAC key. Returns:BinaryString. Returns a raw HMAC digest.NAME_hex(BinaryString value, BinaryString key)Parameters:
valueis binary input data andkeyis the HMAC key. Returns:String. Returns lowercase hexadecimal HMAC text.NAME_b64(BinaryString value, BinaryString key)Parameters:
valueis binary input data andkeyis the HMAC key. Returns:String. Returns Base64 HMAC text with no trailing=padding.
COPYRIGHT AND LICENCE
std/digest/sha is copyright Toby Inkster.
It is free software; you may redistribute it and/or modify it under the terms of either the Artistic License 1.0 or the GNU General Public License version 2.