
找到了解决方案。
String modulusString = "hm2oRCtP6usJKYpq7o1K20uUuL11j5xRrbV4FCQhn/JeXLT21laKK9901P69YUS3bLo64x8G1PkCfRtjbbZCIaa1Ci/BCQX8nF2kZVfrPyzcmeAkq4wsDthuZ+jPInknzUI3TQPAzdj6gim97E731i6WP0MHFqW6ODeQ6Dsp8pc=";String publicExponentString = "AQAB";byte[] modulusBytes = base64.deprebase64(modulusString);byte[] exponentBytes = base64.deprebase64(publicExponentString);BigInteger modulus = new BigInteger(1, modulusBytes);BigInteger publicExponent = new BigInteger(1, exponentBytes);RSAPublicKeySpec rsaPubKey = new RSAPublicKeySpec(modulus, publicExponent);KeyFactory fact = KeyFactory.getInstance("RSA");PublicKey pubKey = fact.generatePublic(rsaPubKey);Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1PADDING");cipher.init(Cipher.ENCRYPT_MODE, pubKey);byte[] plainBytes = clearTextPassword.getBytes("UTF-16LE");byte[] cipherData = cipher.doFinal(plainBytes);String encryptedStringbase64 = base64.enprebase64String(cipherData);欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)