Skip to content

Instantly share code, notes, and snippets.

@briankung
Created October 12, 2017 23:52
Show Gist options
  • Save briankung/40ac8312baafe66c0b288b6722227c12 to your computer and use it in GitHub Desktop.
Save briankung/40ac8312baafe66c0b288b6722227c12 to your computer and use it in GitHub Desktop.
oi.js from PoC||GTFO
function millis() {
return Date.now();
}
function flip_coin() {
n = 0;
then = millis() + 1;
while (millis() <= then) {
n = !n;
}
return n;
}
function get_fair_bit() {
while (1) {
a = flip_coin();
if (a != flip_coin()) {
return (a);
}
}
}
function get_random_byte() {
n = 0;
bits = 8;
while (bits--) {
n <<= 1;
n |= get_fair_bit();
}
return n;
}
// Use it like this.
report_console = function() {
while(1) {
console.log(get_random_byte());
}
}
report_console();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment