I have a custom public key class that generates mod and exp explicitly instead of using the publickey from the java.security. Now how do I initialize the cipher variable for encryption with the mod and exp that I have .
Cipher cipher = Cipher.getInstance("RSA");
String mod = pbkey.getMod();
String exp = pbkey.getExp();
How to achieve equivalent of
cipher.init(Cipher.ENCRYPT_MODE, java.security.PublicKeyVariable);
using the mod and exp?
thanks
Nohsib
Build a
RSAPublicKeySpec, pass it toKeyFactory.generatePublic, then pass the result as the second argument tocipher.init. See this tutorial.