Home

Awesome

Motoko Sha3 and Keccak Library

Supporting:

Usage

var sha = SHA3.Sha3(224);
sha.update([104 : Nat8, 101, 108, 108, 111]);
let result = sha.finalize();

Example

var sha = SHA3.Keccak(512);
let hello = Blob.toArray(Text.encodeUtf8("hello"));
let space = Blob.toArray(Text.encodeUtf8(" "));
let world = Blob.toArray(Text.encodeUtf8("world!"));
sha.update(hello);
sha.update(space);
sha.update(world);
let result = sha.finalize();
let hex = Hex.encode(result);
Debug.print(hex);
// assert ("d50b81a30b0ee3b355ae0b5af973fa28518377822165c76b735404470aaf91553ef4a5cf43a3511f2fc0decfd14da1048e244ec1a94aac2fbde2ae87c2d95455" == hex);

Ref