Skip to content

Instantly share code, notes, and snippets.

@revington
Created November 23, 2017 20:09
Show Gist options
  • Save revington/6f68dab35625e9ed2e3d96db0ad8a327 to your computer and use it in GitHub Desktop.
Save revington/6f68dab35625e9ed2e3d96db0ad8a327 to your computer and use it in GitHub Desktop.
'use strict';
// simple feistel network
function feistel(input) {
var l1, l2, r1, r2, i = 0;
l1 = (input >> 16) & 65535;
r1 = input & 65535;
for (i = 0; i < 3; i++) {
l2 = r1;
r2 = l1 ^ ((((1366 * r1 + 150889) % 1114111) / 1114111.0) * 32767);
l1 = l2;
r1 = r2;
}
return (r1 << 16) + l1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment