Last active
December 21, 2015 12:19
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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