类 HoneyBadgerEncrypt

  • 所有已实现的接口:
    org.springframework.beans.factory.InitializingBean

    public class HoneyBadgerEncrypt
    extends Object
    implements org.springframework.beans.factory.InitializingBean
    The type Honey badger encrypt.
    从以下版本开始:
    : 1.0.0
    作者:
    : longfa 蜜獾 还可以用来当作吉祥物品
    • 字段详细资料

      • AES_KEY

        public static byte[] AES_KEY
        The Aes key.
      • AES_IV

        public static byte[] AES_IV
        The Aes iv.
      • sm4

        public static cn.hutool.crypto.symmetric.SM4 sm4
        The constant sm4.
      • rsa

        public static cn.hutool.crypto.asymmetric.RSA rsa
        The constant rsa.
      • aes

        public static cn.hutool.crypto.symmetric.AES aes
        The constant aes.
      • PRIVATE_KEY

        public static String PRIVATE_KEY
        The constant PRIVATE_KEY.
      • PUBLIC_KEY

        public static String PUBLIC_KEY
        The constant PUBLIC_KEY.
      • digester

        public static final cn.hutool.crypto.digest.Digester digester
        The constant digester.
      • SM4_KEY

        public static byte[] SM4_KEY
      • SM4_IV

        public static byte[] SM4_IV
    • 构造器详细资料

      • HoneyBadgerEncrypt

        public HoneyBadgerEncrypt()
    • 方法详细资料

      • afterPropertiesSet

        public void afterPropertiesSet()
        指定者:
        afterPropertiesSet 在接口中 org.springframework.beans.factory.InitializingBean
      • aesEncrypt

        public String aesEncrypt​(String content)
        aes加密
        参数:
        content - 文本内容跟
        返回:
        加密字符串 16进制
      • aesDecrypt

        public String aesDecrypt​(String encrypt)
        aes解密
        参数:
        encrypt - 密文
        返回:
        明文 string
      • sm4Encrypt

        public String sm4Encrypt​(String context)
        SM4 国密
        参数:
        context - 明文
        返回:
        密文 string
      • sm4Decrypt

        public String sm4Decrypt​(String encrypt)
        过密算法 解密
        参数:
        encrypt - 密文
        返回:
        明文 string
      • rsaEncrypt

        public String rsaEncrypt​(String content)
        RSA非对称加密算法
        参数:
        content - 明文
        返回:
        密文 string
      • rsaDecrypt

        public String rsaDecrypt​(String encrypt)
        RSA非对称加密解密
        参数:
        encrypt - 密文
        返回:
        明文 string
      • sm3DigesterObject

        public String sm3DigesterObject​(String content)
        Sm 3 digester object string.
        参数:
        content - the content
        返回:
        the string
      • sm3DigesterFile

        public String sm3DigesterFile​(File file)
        Sm 3 digester file string.
        参数:
        file - the file
        返回:
        the string
      • initHybridEncryption

        public void initHybridEncryption​(CipherMode cipherMode,
                                         boolean dynamic)
        初始化混合加密实例 动态生成密钥 仅支持SM4-RSA AES-RSA 两种混合模式
      • initHybridDecryption

        public void initHybridDecryption​(CipherMode cipherMode,
                                         boolean dynamic)
        初始化解密实例
        参数:
        cipherMode - 加密模式
        dynamic - 动态
      • getSm4KeyRSACiphertext

        public static String getSm4KeyRSACiphertext()
        返回:
        rsa加密后的sm4密钥
      • getAesKeyRSACiphertext

        public static String getAesKeyRSACiphertext()
        返回:
        rsa加密后的aes密钥
      • setRSACiphertextForSM4Key

        public static void setRSACiphertextForSM4Key​(String sm4RSACiphertext)
        创建SM4实例 请配合拦截器获取过滤器使用 私钥解密 公钥加密 支持动态密钥 也就是每一次加 密钥都不一样 这个模式 仅支持传输加密 最好不要用来做存储加密方式 否则 可能导致数据无法复原
        参数:
        sm4RSACiphertext - sm4key
      • setRSACiphertextForAESKey

        public static void setRSACiphertextForAESKey​(String aesKeyRSACiphertext)
        初始化aes加密 创建AES实例 解密
        参数:
        aesKeyRSACiphertext - aesKey
      • sm4RsaDecrypt

        public String sm4RsaDecrypt​(String encrypt)
        sm4 rsa 混合加密模式 解密
        参数:
        encrypt - 密文
        返回:
        String
      • sm4RsaEncrypt

        public String sm4RsaEncrypt​(String content)
        sm4Rsa混合加密
        参数:
        content - 明文
        返回:
        密文
      • aesRsaEncrypt

        public String aesRsaEncrypt​(String content)
        aesRsa混合加密
        参数:
        content - 明文
        返回:
        密文
      • aesRsaDecrypt

        public String aesRsaDecrypt​(String encrypt)
        aes rsa 混合加密模式 解密
        参数:
        encrypt - 密文
        返回:
        String