Socket
Book a DemoInstallSign in
Socket

as-hmac-sha2

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

as-hmac-sha2

SHA-256, HMAC-SHA256, SHA-512 and HMAC-SHA512 for AssemblyScript.

1.0.2
latest
Source
npmnpm
Version published
Weekly downloads
10
-9.09%
Maintainers
1
Weekly downloads
 
Created
Source

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);

Keywords

assemblyscript

FAQs

Package last updated on 15 Oct 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.