Reputation: 75
How can I encrypt/decrypt a string myself with N, P, Q, and public/private keys e and d?
I tried casting each individual character as a int, performing the calculations, and casting it back as a char, but I seem to get the same character after encryption for different characters.
That is, the characters don't seem to be mapping one to one.
for( int i = 0; i < message.length() - 1; i++ )
{
ori = (int)message[ i ];
for( int j = 0; j < e; j++ )
ori = ( (int)message[ i ] * ori ) % N;
message[ i ] = (char)ori;
}
N is the product of two primes, e is the exponent of the number I'm trying to encrypt.
Upvotes: 0
Views: 1562
Reputation: 5668
Some things to note about this:
Upvotes: 1