// Then encrypt along with the nonce and the hash code
byte[] nonce = nextNonce();
byte[] hash = generateHashCode(nonce, inbytes);
int index = cipher.update(hash, 0, HASH_CODE_SIZE, output, 0);
index = cipher.update(nonce, 0, NONCE_SIZE, output, index);
if (inbytes.length == 0) {
cipher.doFinal(output, index);
}
else {
cipher.doFinal(inbytes, 0, inbytes.length, output, index);