类 AESEncrypt


  • public class AESEncrypt
    extends Object
    AES加密 对称加密
    作者:
    ln
    • 构造器详细资料

      • AESEncrypt

        public AESEncrypt()
    • 方法详细资料

      • encrypt

        public static byte[] encrypt​(byte[] plainBytes,
                                     String password)
        数据通过password加密
        参数:
        plainBytes - 需要加密的数据
        password - 秘钥
        返回:
        加密后的数据
      • encrypt

        public static EncryptedData encrypt​(byte[] plainBytes,
                                            org.bouncycastle.crypto.params.KeyParameter aesKey)
        数据通过KeyParameter加密
        参数:
        plainBytes - 需要加密的数据
        aesKey - 秘钥
        返回:
        加密后的数据
      • encrypt

        public static EncryptedData encrypt​(byte[] plainBytes,
                                            byte[] iv,
                                            org.bouncycastle.crypto.params.KeyParameter aesKey)
                                     throws RuntimeException
        数据通过KeyParameter和初始化向量加密
        参数:
        plainBytes - 需要加密的数据
        iv - 初始化向量
        aesKey - 秘钥
        返回:
        加密后的数据
        抛出:
        RuntimeException
      • decrypt

        public static byte[] decrypt​(byte[] dataToDecrypt,
                                     String password)
                              throws CryptoException
        数据通过password解密
        参数:
        dataToDecrypt - 需要解密的数据
        password - 秘钥
        返回:
        解密后的数据
        抛出:
        CryptoException
      • decrypt

        public static byte[] decrypt​(EncryptedData dataToDecrypt,
                                     org.bouncycastle.crypto.params.KeyParameter aesKey)
                              throws CryptoException
        数据通过KeyParameter解密
        参数:
        dataToDecrypt - 需要解密的数据
        aesKey - 秘钥
        返回:
        解密后的数据
        抛出:
        CryptoException