An open API service indexing awesome lists of open source software.

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

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 ]
```