Skip to content

ribbles/PublicPrivateKeyEncryptionExample

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

Public Private Key Encryption Example

Simple working example of public private key encryption

References

Useful code

Creating the public and private key

int p = 17; // 1st large prime (larger)
int q = 13; // 2nd large prime
int pubKey1 = p*q;
int pubKey2 = 11;// < pubKey1 - 65537 is commonly used
int privKey = CalculateExtendedEuclideanAlgorithm(pubKey2, (p - 1) * (q - 1));

Encryption

var cipherText = BigInteger.Pow(input, pubKey2) % pubKey1;

Decryption

var plainText = (char)(BigInteger.Pow(cipherText, privKey) % pubKey1);

About

Simple working example of public private key encryption

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages