symmetric-state.js
function encryptAndHash (state, ciphertext, plaintext) {
  assert(state.byteLength === STATELEN)
  assert(ciphertext.byteLength != null)
  assert(plaintext.byteLength != null)

  var cstate = state.subarray(CIPHER_BEGIN, CIPHER_END)
  var h = state.subarray(HASH_BEGIN, HASH_END)

  cipherState.encryptWithAd(cstate, ciphertext, h, plaintext)
  encryptAndHash.bytesRead = cipherState.encryptWithAd.bytesRead
  encryptAndHash.bytesWritten = cipherState.encryptWithAd.bytesWritten
  mixHash(state, ciphertext.subarray(0, encryptAndHash.bytesWritten))
}
function encryptAndHash (state, ciphertext, plaintext) {
  assert(state.byteLength === STATELEN)
  assert(ciphertext.byteLength != null)
  assert(plaintext.byteLength != null)

  var cstate = state.subarray(CIPHER_BEGIN, CIPHER_END)
  var h = state.subarray(HASH_BEGIN, HASH_END)

  cipherState.encryptWithAd(cstate, ciphertext, h, plaintext)
  encryptAndHash.bytesRead = cipherState.encryptWithAd.bytesRead
  encryptAndHash.bytesWritten = cipherState.encryptWithAd.bytesWritten
  mixHash(state, ciphertext.subarray(0, encryptAndHash.bytesWritten))
}
function encryptAndHash ( state , ciphertext , plaintext ) { assert ( state . byteLength === STATELEN ) assert ( ciphertext . byteLength != null ) assert ( plaintext . byteLength != null ) var cstate = state . subarray ( CIPHER_BEGIN , CIPHER_END ) var h = state . subarray ( HASH_BEGIN , HASH_END ) cipherState . encryptWithAd ( cstate , ciphertext , h , plaintext ) encryptAndHash . bytesRead = cipherState . encryptWithAd . bytesRead encryptAndHash . bytesWritten = cipherState . encryptWithAd . bytesWritten mixHash ( state , ciphertext . subarray ( 0 , encryptAndHash . bytesWritten ) ) }
ciphertext is the output here
ciphertext is the output here