I want to encrypt a small string in javascript using RSA with public keys and then decrypt that string in java server side code using private keys.
I am using this code in javascript: http://www-cs-students.stanford.edu/~tjw/jsbn/ Example at: http://www-cs-students.stanford.edu/~tjw/jsbn/rsa2.html
and this code on java side: Encrypting string in javascript and decryption in java
Both of codes work good independently but they do not understand each other. Need to solve this today or I am open to accept any other asymmetrical algorithm that works this way.
You are using raw encryption on the Java side and RSA encryption using PKCS#1 v1.5 padding on the Java Card side. You should try and use Java RSA through the
javax.crypto.Cipher.getInstance("RSA/None/PKCS1Padding"). Don't forget to remove any base 64 encoding if that is present.