MCPcopy Index your code
hub / github.com/f0ng/autoDecoder / encrypt

Method encrypt

src/com/autoDecoder/util/RSAencode.java:68–78  ·  view source on GitHub ↗

RSA公钥加密 @param str 加密字符串 @param publicKey 公钥 @return 密文 @throws Exception 加密过程中的异常信息

(String str,String publicKey)

Source from the content-addressed store, hash-verified

66 * @throws Exception 加密过程中的异常信息
67 */
68 public static String encrypt(String str,String publicKey) throws Exception {
69 //base64编码的公钥
70 byte[] decoded = decryptBASE64(publicKey);
71 Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
72 RSAPublicKey pubKey = (RSAPublicKey) KeyFactory.getInstance("RSA").generatePublic(new X509EncodedKeySpec(decoded));
73 //RSA加密
74 Cipher cipher = Cipher.getInstance("RSA");
75 cipher.init(Cipher.ENCRYPT_MODE, pubKey);
76 String outStr = encryptBASE64(cipher.doFinal(str.getBytes("UTF-8")));
77 return outStr;
78 }
79
80 /**
81 * RSA私钥解密

Callers 2

mainMethod · 0.95
encryptKeyivmodeMethod · 0.45

Calls 2

decryptBASE64Method · 0.95
encryptBASE64Method · 0.95

Tested by

no test coverage detected