1、公钥和私钥这边已经匹配过了是正常的
2、使用RSA加密方法加密
String sign = new String(Base64.encodeBase64(RSAUtil.sign(inputContent, privateKeyCode)),"utf-8");
直接报错java.security.SignatureException: Could not sign data inputContent是需要加密的字符串转字节;privateKeyCode是RSA私钥转字节
导的包不对吧
import lombok.SneakyThrows;
import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;
import java.util.Base64;
/**
* @author liuyh
* @Description:
* @date 2020/10/269:53
*/
public class BaseUtils {
final static BASE64Encoder encoder = new BASE64Encoder();
final static BASE64Decoder decoder = new BASE64Decoder();
//加密
@SneakyThrows
public static String getEncoder(String msg) {
byte[] textByte = msg.getBytes("UTF-8");
String encodedText = encoder.encode(textByte);
return encodedText;
}
//解密
public static String getDecoder(String msg) throws Exception {
return (new String(decoder.decodeBuffer(msg), "UTF-8"));
}
}