Skip to content

Instantly share code, notes, and snippets.

@eugeneglova
Last active December 21, 2015 12:19
Show Gist options
  • Save eugeneglova/6304833 to your computer and use it in GitHub Desktop.
Save eugeneglova/6304833 to your computer and use it in GitHub Desktop.
trying to make public and private key based on http://www.youtube.com/watch?v=3QnD2c4Xovk
function enc(exp, private) {
return Math.pow(exp, private) % 17;
}
function calc(pub1, private1, private2) {
var a, b;
a = enc(pub1, private1);
b = enc(pub1, private2);
return enc(b, private1) === enc(a, private2);
}
var i, j;
for (i = 0; i < 32; i++) {
for (j = 0; j < 32; j++) {
if (calc(3, i, j)) {
console.count('valid');
} else {
console.count('invalid');
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment