Class MGL_RSACoder

java.lang.Object
tech.mgl.core.tools.MGL_RSACoder

public abstract class MGL_RSACoder extends Object
RSA安全编码组件
Since:
1.0
Version:
1.0
Author:
MGL
  • Field Details

  • Constructor Details

    • MGL_RSACoder

      public MGL_RSACoder()
  • Method Details

    • sign

      public static String sign(byte[] data, String privateKey) throws Exception
      用私钥对信息生成数字签名
      Parameters:
      data - 加密数据
      privateKey - 私钥
      Returns:
      Throws:
      Exception
    • verify

      public static boolean verify(byte[] data, String publicKey, String sign)
      校验数字签名
      Parameters:
      data - 加密数据
      publicKey - 公钥
      sign - 数字签名
      Returns:
      校验成功返回true 失败返回false
      Throws:
      Exception
    • decryptByPrivateKey

      public static byte[] decryptByPrivateKey(byte[] data, String key) throws Exception
      解密
      用私钥解密
      Parameters:
      data -
      key -
      Returns:
      Throws:
      Exception
    • decryptByPublicKey

      public static byte[] decryptByPublicKey(byte[] data, String key) throws Exception
      解密
      用公钥解密
      Parameters:
      data -
      key -
      Returns:
      Throws:
      Exception
    • encryptByPublicKey

      public static byte[] encryptByPublicKey(byte[] data, String key) throws Exception
      加密
      用公钥加密
      Parameters:
      data -
      key -
      Returns:
      Throws:
      Exception
    • encryptByPrivateKey

      public static byte[] encryptByPrivateKey(byte[] data, String key) throws Exception
      加密
      用私钥加密
      Parameters:
      data -
      key -
      Returns:
      Throws:
      Exception
    • getPrivateKey

      public static String getPrivateKey(Map<String,Object> keyMap) throws Exception
      取得私钥
      Parameters:
      keyMap -
      Returns:
      Throws:
      Exception
    • getPublicKey

      public static String getPublicKey(Map<String,Object> keyMap) throws Exception
      取得公钥
      Parameters:
      keyMap -
      Returns:
      Throws:
      Exception
    • initKey

      public static Map<String,Object> initKey() throws Exception
      初始化密钥
      Returns:
      Throws:
      Exception