Skip to content

Commit 62ace35

Browse files
add basic hash functions
1 parent 52efc00 commit 62ace35

File tree

6 files changed

+51
-1
lines changed

6 files changed

+51
-1
lines changed

.vscode/settings.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"deno.enable": true,
3+
"deno.suggest.imports.hosts": {
4+
"https://deno.land": false
5+
}
6+
}

README.md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,28 @@
1-
# hash
1+
# Hash
2+
3+
This module represents a collection of hash functions.
4+
5+
## Usage Examples
6+
### CRC32
7+
8+
```ts
9+
10+
import crc32 from 'https://deno.land/x/hash/mod-crc32.ts'
11+
12+
console.log(crc32.str("SheetJS"))
13+
console.log(crc32.bstr("SheetJS"))
14+
console.log(crc32.buf([83, 104, 101, 101, 116, 74, 83]))
15+
16+
```
17+
18+
### SHA 256
19+
20+
```ts
21+
22+
import hashJs from 'https://deno.land/x/hash/mod-hashjs.ts'
23+
24+
console.log(hashJs.sha256().update('abc').digest('hex'))
25+
26+
```
27+
28+

mod-crc32.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
import crc32 from "https://cdn.esm.sh/v57/crc-32@1.2.0/es2021/crc-32.js"
3+
export default crc32

mod-hashjs.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
import hashjs from "https://cdn.esm.sh/v57/hash.js@1.1.7/es2021/hash.js";
3+
export default hashjs

usage-examples/crc32.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// for details check https://www.npmjs.com/package/crc-32
2+
import crc32 from '../mod-crc32.ts'
3+
4+
console.log(crc32.str("SheetJS"))
5+
console.log(crc32.bstr("SheetJS"))
6+
console.log(crc32.buf([83, 104, 101, 101, 116, 74, 83]))
7+

usage-examples/sha256.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// for details check https://www.npmjs.com/package/hash.js
2+
import hashJs from '../mod-hashjs.ts'
3+
4+
console.log(hashJs.sha256().update('abc').digest('hex'))

0 commit comments

Comments
 (0)