Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jedisct1/as-hmac-sha2
SHA-256, SHA-512, HMAC-SHA-256, HMAC-SHA-512 for AssemblyScript.
https://github.com/jedisct1/as-hmac-sha2
assemblyscript hmac sha256 sha512
Last synced: 4 months ago
JSON representation
SHA-256, SHA-512, HMAC-SHA-256, HMAC-SHA-512 for AssemblyScript.
- Host: GitHub
- URL: https://github.com/jedisct1/as-hmac-sha2
- Owner: jedisct1
- Created: 2021-05-13T14:19:19.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-09-23T11:03:39.000Z (over 2 years ago)
- Last Synced: 2024-10-06T18:16:27.460Z (4 months ago)
- Topics: assemblyscript, hmac, sha256, sha512
- Language: TypeScript
- Homepage:
- Size: 14.6 KB
- Stars: 14
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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:
```typescript
let msg = Uint8Array.wrap(String.UTF8.encode("test"));
let h = Sha256.hash(msg);
```Chunked input:
```typescript
let st = new Sha256();
st.update(msg1);
st.update(msg2);
let h = st.final();
```HMAC:
```typescript
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:
```typescript
let ok = verify(mac, expected_mac);
```Constant-time hexadecimal encoding/decoding:
```typescript
let hex = bin2hex(h);
let bin = hex2bin(hex);
```