src/main/java/com/se/simu/helper/RsaHelper.java
@@ -137,4 +137,17 @@ return outStr; } public static String encrypt(String key, String str) throws Exception { byte[] decoded = Base64.decodeBase64(key); RSAPublicKey pubKey = (RSAPublicKey) KeyFactory.getInstance("RSA").generatePublic(new X509EncodedKeySpec(decoded)); Cipher cipher = Cipher.getInstance("RSA"); cipher.init(Cipher.ENCRYPT_MODE, pubKey); String outStr = Base64.encodeBase64String(cipher.doFinal(str.getBytes(StandardCharsets.UTF_8))); return outStr; } }