public byte [ ] encrypt ( final byte [ ] iv , final byte [ ] message ) throws RuntimeException { AEADParameters aeadParams = new AEADParameters ( new KeyParameter ( key ) , TAG_LENGTH , iv , authData ) ; cipher . init ( true , aeadParams ) ; byte [ ] cipherText = newBuffer ( cipher . getOutputSize ( message . length ) ) ; int outputOffset = cipher . processBytes ( message , 0 , message . length , cipherText , 0 ) ; try { cipher . doFinal ( cipherText , outputOffset ) ; } catch ( InvalidCipherTextException e ) { throw new RuntimeException ( "Error: " , e ) ; } return cipherText ; }
Given the iv encrypt the provided data