Created
December 1, 2016 16:48
-
-
Save kiironoaki/902329f5318a14de8a6e9b039b445d1d to your computer and use it in GitHub Desktop.
Deffie-Hellman protocol sandbox
This file contains 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
<?php | |
// private | |
$A = 15; // Alice | |
echo "Alice private key: " . $A . "(A)\n"; | |
$B = 5; // Bob | |
echo "Bob private key: " . $B . "(B)\n"; | |
// public | |
$a = pow(11, $A) % 23; // Alice | |
echo "\nAlice public key: " . $a . "\n"; | |
$b = pow(11, $B) % 23; // Bob | |
echo "Bob public key: " . $b . "\n"; | |
echo "\nFrom Bob: " . (pow($b, $A) % 23) . "\n"; | |
echo "From Alice: " . (pow($a, $B) % 23) . "\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment