Skip to content

gnlow/bitwise-shuffle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 

Repository files navigation

bitwise-shuffle

Bitwise shuffle for two-way hashing

Use (Deno)

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 ]

About

Bitwise shuffle for two-way hashing

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published