Skip to content

Commit d769ac8

Browse files
📚 docs(README): First draft.
1 parent 4de5e24 commit d769ac8

File tree

2 files changed

+11
-18
lines changed

2 files changed

+11
-18
lines changed

README.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,16 @@
44
SHA2 bytestring hashing for JavaScript.
55
See [docs](https://string-hashing.github.io/sha2/index.html).
66

7-
> :building_construction: Caveat emptor! This is work in progress. Code may be
8-
> working. Documentation may be present. Coherence may be. Maybe.
9-
10-
> :warning: Depending on your environment, the code may require
11-
> `regeneratorRuntime` to be defined, for instance by importing
12-
> [regenerator-runtime/runtime](https://www.npmjs.com/package/regenerator-runtime).
7+
```js
8+
import * as ascii from '@codec-bytes/ascii';
9+
import * as base16 from '@codec-bytes/base16';
10+
import {sha512} from '@string-hashing/sha2';
11+
const string = 'The quick brown fox jumps over the lazy dog';
12+
const bytes = ascii.encode(string);
13+
const digest = sha512(bytes, bytes.length * 8, alloc(64));
14+
digest; // [0x07, 0xe5, 0x47, 0xd9, 0x58, 0x6f, 0x6a, 0x73, 0xf7, 0x3f, ...]
15+
base16.decode(digest); // '07E547D9586F6A73F73FBAC0435ED76951218FB7D0C8D788A309D785436B...'
16+
```
1317

1418
[![License](https://img.shields.io/github/license/string-hashing/sha2.svg)](https://raw.githubusercontent.com/string-hashing/sha2/main/LICENSE)
1519
[![Version](https://img.shields.io/npm/v/@string-hashing/sha2.svg)](https://www.npmjs.org/package/@string-hashing/sha2)

doc/manual/usage.md

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,6 @@
11
# Usage
22

3-
> :warning: Depending on your environment, the code may require
4-
> `regeneratorRuntime` to be defined, for instance by importing
5-
> [regenerator-runtime/runtime](https://www.npmjs.com/package/regenerator-runtime).
6-
7-
First, require the polyfill at the entry point of your application
8-
```js
9-
await import('regenerator-runtime/runtime.js');
10-
// or
11-
import 'regenerator-runtime/runtime.js';
12-
```
13-
14-
Then, import the library where needed
3+
Import the library where needed
154
```js
165
const sha2 = await import('@string-hashing/sha2');
176
// or

0 commit comments

Comments
 (0)