类 RsaUtils

java.lang.Object
cn.iosd.starter.encrypt.rsa.utils.RsaUtils

public class RsaUtils extends Object
作者:
ok1996
  • 构造器详细资料

    • RsaUtils

      public RsaUtils()
  • 方法详细资料

    • generateKeyPair

      public static KeyPair generateKeyPair() throws NoSuchAlgorithmException
      生成 RSA 密钥对
      返回:
      RSA 密钥对
      抛出:
      NoSuchAlgorithmException
    • encrypt

      public static String encrypt(String data, String publicKey) throws Exception
      使用公钥加密数据
      参数:
      data - 待加密数据
      publicKey - 公钥字符串
      返回:
      加密后的数据字符串
      抛出:
      Exception
    • decrypt

      public static String decrypt(String data, String privateKey) throws Exception
      使用私钥解密数据
      参数:
      data - 待解密数据字符串
      privateKey - 私钥字符串
      返回:
      解密后的数据
      抛出:
      Exception
    • timestampValidation

      public static void timestampValidation(RsaProperties.TimestampValidation timestampValidation, String contentsDecrypt) throws com.fasterxml.jackson.core.JsonProcessingException
      时间戳校验方法
      参数:
      timestampValidation - 校验配置参数
      contentsDecrypt - 加密文本
      抛出:
      com.fasterxml.jackson.core.JsonProcessingException - 解析异常抛出