Home

Awesome

Crypto Package for Motoko

Packages

Package NameDescriptionSpecPath
SHASHA224 and SHA256 hash algorithmsFIPS 180-4crypto/SHA/..
AESAdvanced Encryption Standard (AES)FIPS 197crypto/AES
HMACKeyed-Hash Message Authentication Code (HMAC)FIPS 198-1crypto/HMAC

Usage

SHA

SHA256.sum(Blob.toArray(Text.encodeUtf8("hello world\n"));
// "a948904f2f0f479b8f8197694b30184b0d2ed1c1cd2a1ec0fb85d299a192a447"

let h = SHA256.New();
h.write(Blob.toArray(Text.encodeUtf8("hello world\n")));
h.sum([]);
// "a948904f2f0f479b8f8197694b30184b0d2ed1c1cd2a1ec0fb85d299a192a447"

HMAC

let h = HMAC.New(SHA256.New, []);
h.write(Blob.toArray(Text.encodeUtf8("hello world\n")));
h.sum([]);
// "d4452dbfe1fe25bf6c2fa79172dae3d7e2950de69f76e6c23188c49bfba4372f"