程序包 cn.godmao.utils

类 RSAUtil

java.lang.Object
cn.godmao.utils.RSAUtil

public class RSAUtil extends Object
非对称加密,私钥加密的数据,使用公钥解密,公钥加密的数据,使用私钥解密
  • 构造器详细资料

    • RSAUtil

      public RSAUtil()
  • 方法详细资料

    • genKeyPair

      public static RSAUtil.RsaKeyPair genKeyPair() throws Exception

      生成密钥对(公钥和私钥)

      返回:
      抛出:
      Exception
    • sign

      public static byte[] sign(byte[] data, byte[] keyBytes) throws Exception

      用私钥对信息生成数字签名

      参数:
      data - 已加密数据
      keyBytes - 私钥
      返回:
      抛出:
      Exception
    • decryptByPrivateKey

      public static byte[] decryptByPrivateKey(byte[] encryptedData, byte[] privateKey) throws Exception

      私钥解密

      参数:
      encryptedData - 已加密数据
      privateKey - 私钥
      返回:
      抛出:
      Exception
    • decryptByPublicKey

      public static byte[] decryptByPublicKey(byte[] encryptedData, byte[] keyBytes) throws Exception

      公钥解密

      参数:
      encryptedData - 已加密数据
      keyBytes - 公钥
      返回:
      抛出:
      Exception
    • encryptByPublicKey

      public static byte[] encryptByPublicKey(byte[] data, byte[] publicKey) throws Exception

      公钥加密

      参数:
      data - 源数据
      publicKey - 公钥
      返回:
      抛出:
      Exception
    • encryptByPrivateKey

      public static byte[] encryptByPrivateKey(byte[] data, byte[] keyBytes) throws Exception

      私钥加密

      参数:
      data - 源数据
      返回:
      抛出:
      Exception
    • main

      public static void main(String[] args) throws Exception
      抛出:
      Exception
    • getSignToken

      public static String getSignToken(Map map)
    • getMD5Value

      public static String getMD5Value(String value)
    • createSign

      public static String createSign(SortedMap<Object,Object> parameters, String key)
      生成签名
    • getMD5

      public static String getMD5(String str)
      对字符串进行MD5加密
    • getMd5

      public static String getMd5(String msg)