Class AesBytesEncryptor

  • All Implemented Interfaces:
    BytesEncryptor

    public final class AesBytesEncryptor
    extends java.lang.Object
    implements BytesEncryptor
    Encryptor that uses AES encryption.
    • Constructor Detail

      • AesBytesEncryptor

        public AesBytesEncryptor​(java.lang.String password,
                                 java.lang.CharSequence salt,
                                 BytesKeyGenerator ivGenerator)
        Constructs an encryptor that uses AES encryption. Example: AesBytesEncryptor encryptor = new AesBytesEncryptor(yourPassword, 5c0744940b5c369b, KeyGenerators.secureRandom(16)); Constructed encryptor uses CBC mode encryption. To specify a different encryption mode, use AesBytesEncryptor(String, CharSequence, BytesKeyGenerator, CipherAlgorithm).
        Parameters:
        password - the password value
        salt - the hex-encoded salt value
        ivGenerator - the generator used to generate the initialization vector
      • AesBytesEncryptor

        public AesBytesEncryptor​(java.lang.String password,
                                 java.lang.CharSequence salt,
                                 BytesKeyGenerator ivGenerator,
                                 AesBytesEncryptor.CipherAlgorithm alg)
        Constructs an encryptor that uses AES encryption. Example: AesBytesEncryptor encryptor = new AesBytesEncryptor(yourPassword, 5c0744940b5c369b, KeyGenerators.secureRandom(16), CipherAlgorithm.GCM);
        Parameters:
        password - the password value
        salt - the hex-encoded salt value
        ivGenerator - the generator used to generate the initialization vector
        alg - the AesBytesEncryptor.CipherAlgorithm to be used
    • Method Detail

      • encrypt

        public byte[] encrypt​(byte[] bytes)
        Description copied from interface: BytesEncryptor
        Encrypt the byte array.
        Specified by:
        encrypt in interface BytesEncryptor
      • decrypt

        public byte[] decrypt​(byte[] encryptedBytes)
        Description copied from interface: BytesEncryptor
        Decrypt the byte array.
        Specified by:
        decrypt in interface BytesEncryptor