https://github.com/gnlow/bitwise-shuffle
Bitwise shuffle for two-way hashing
https://github.com/gnlow/bitwise-shuffle
bitwise hash random shuffle
Last synced: 3 days ago
JSON representation
Bitwise shuffle for two-way hashing
- Host: GitHub
- URL: https://github.com/gnlow/bitwise-shuffle
- Owner: gnlow
- License: mit
- Created: 2020-06-23T13:23:52.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-06-24T01:42:05.000Z (over 5 years ago)
- Last Synced: 2025-05-30T01:51:28.633Z (4 months ago)
- Topics: bitwise, hash, random, shuffle
- Language: TypeScript
- Homepage:
- Size: 5.86 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# bitwise-shuffle
Bitwise shuffle for two-way hashing
## Use (Deno)
```ts
import {shuffle, unshuffle, random} from "https://raw.githubusercontent.com/gnlow/bitwise-shuffle/master/mod.ts"const key = [2, 0, 1, 3]
const hash = shuffle(key)
console.log(hash(0b1010)) // 6 = 0110(2)
/*
input: 10 = 1010(2)
key: 2013
\//|
//\|
||||
output: 6 = 0110(2)
*/const unhash = unshuffle(key)
console.log(unhash(0b0110)) // 10 = 1010(2)console.log(random(4)) // (ex) [ 1, 0, 2, 3 ]
```