13693261870
2025-04-08 3417cf014a65765e02696c1d121ce58b2b4a8aed
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;
    }
}