box_nonce_len method
Implementation
Uint8List box_nonce_len(
Uint8List message, final int moff, final int mlen, Uint8List theNonce) {
// check message
if (!(message != null &&
message.length >= (moff + mlen) &&
theNonce != null &&
theNonce.length == nonceLength)) return null;
// message buffer
Uint8List m = Uint8List(mlen + zerobytesLength);
// cipher buffer
Uint8List c = Uint8List(m.length);
for (int i = 0; i < mlen; i++) m[i + zerobytesLength] = message[i + moff];
if (0 != TweetNaclFast.crypto_secretbox(c, m, m.length, theNonce, _key))
return null;
// TBD optimizing ...
// wrap byte_buf_t on c offset@boxzerobytesLength
///return new byte_buf_t(c, boxzerobytesLength, c.length-boxzerobytesLength);
Uint8List ret = Uint8List(c.length - boxzerobytesLength);
for (int i = 0; i < ret.length; i++) ret[i] = c[i + boxzerobytesLength];
return ret;
}