i followed the step by step procedure how to encrypt and decipher a message based on a basic RSA encryption/deciphering steps from this article The RSA public key cryptographic system (in Technology > Encryption @ iusmentis.com)

public class RSA { public static void main(String[] args) { int p = 5, q = 11, e = 7, d = 23; int encrypted = encrypt(2, e, p, q); System.out.println("Encrypted :" + encrypted); int deciphered = decipher(encrypted, d, p, q); System.out.println("Deciphered" + deciphered); } public static int encrypt(int sampleChar, int e, int p, int q) { return (int) (Math.pow(sampleChar, e) % (p * q)); } public static int decipher(int encryptedSampleChar, int d, int p, int q) { return (int) (Math.pow(encryptedSampleChar, d) % (p * q)); } }

an original message which is 2 is encrypted by [2 raise to e modulo of (p * q)] resulting into 18

but in the state of deciphering by [18 raise to d modulo of (p * q)] results into 37, instead of 2

i directly assigned 23 as the value of d, to lessen some code because its already given on the article sample

i just dont get it right, why do i get 37 instead of 2 when i try to revert the process (deciphering) ?