Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HMAC-SHA-256 and HMAC-SHA-512 for AssemblyScript

Self-contained implementations of SHA-256, SHA-512, HMAC-SHA-256 and HMAC-SHA-512 for AssemblyScript.

Simple hashing:

let msg = Uint8Array.wrap(String.UTF8.encode("test"));
let h = Sha256.hash(msg);

Chunked input:

let st = new Sha256();
st.update(msg1);
st.update(msg2);
let h = st.final();

HMAC:

let msg = Uint8Array.wrap(String.UTF8.encode("message"));
let key = Uint8Array.wrap(String.UTF8.encode("key"));
let mac = Sha256.hmac(msg, key);

Constant-time check for equality:

let ok = verify(mac, expected_mac);

Constant-time hexadecimal encoding/decoding:

let hex = bin2hex(h);
let bin = hex2bin(hex);

About

SHA-256, SHA-512, HMAC-SHA-256, HMAC-SHA-512 for AssemblyScript.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages