Created
November 19, 2012 13:37
-
-
Save harveytoro/4110690 to your computer and use it in GitHub Desktop.
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
#include <stdio.h> | |
int main(int argc, char *argv[]) { | |
int e = 1; // variable part of the Modular exponentiation algorithm. | |
int charInput = 97; // ASCII value of a | |
//Public keys | |
int n = 3233; | |
int k = 17; | |
//private keys | |
int j = 2753; | |
// Modular exponentiation algorithm http://en.wikipedia.org/wiki/Modular_exponentiation | |
for (int ei = 0; ei < k; ei++) { | |
e = ((e * charInput) % n); | |
} | |
printf("%i\n", e); //Encryption | |
/* | |
Descryption | |
*/ | |
int d = 1; // variable part of the Modular exponentiation algorithm. | |
for (int ei = 0; ei < j; ei++) { | |
d = ((d * e) % n); | |
} | |
printf("%i\n", d); //Decryption | |
} // main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment