src/main/java/com/yb/helper/RsaHelper.java
@@ -3,6 +3,7 @@
import org.apache.commons.codec.binary.Base64;
import javax.crypto.Cipher;
import java.io.IOException;
import java.security.KeyFactory;
import java.security.interfaces.RSAPublicKey;
import java.security.spec.X509EncodedKeySpec;
@@ -10,7 +11,7 @@
public class RsaHelper {
    //    RsA秘钥加密
    public static String encrypt(String key, String str) throws Exception {
        // Base64编码的公钥
        try {
        byte[] decoded = Base64.decodeBase64(key + "");
        RSAPublicKey pubKey = (RSAPublicKey) KeyFactory.getInstance("RSA").generatePublic(new X509EncodedKeySpec(decoded));
@@ -22,6 +23,12 @@
        String outStr = Base64.encodeBase64String(cipher.doFinal(str.getBytes("UTF-8")));
        return outStr;
        }  catch (IOException e) {
            System.out.println(e.getMessage());
            return null;
        }
        // Base64编码的公钥
    }
}