Skip to content

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

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

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages