Blake2bDigest constructor

Blake2bDigest({
  1. int digestSize = 64,
  2. Uint8List? key,
  3. Uint8List? salt,
  4. Uint8List? personalization,
})

Implementation

Blake2bDigest(
    {int digestSize = 64,
    Uint8List? key,
    Uint8List? salt,
    Uint8List? personalization}) {
  _buffer = Uint8List(_blockSize);

  if (digestSize < 1 || digestSize > 64) {
    throw ArgumentError('Invalid digest length (required: 1 - 64)');
  }
  _digestLength = digestSize;
  if (salt != null) {
    if (salt.length != 16) {
      throw ArgumentError('salt length must be exactly 16 bytes');
    }
    _salt = Uint8List.fromList(salt);
  }
  if (personalization != null) {
    if (personalization.length != 16) {
      throw ArgumentError('personalization length must be exactly 16 bytes');
    }
    _personalization = Uint8List.fromList(personalization);
  }
  if (key != null) {
    if (key.length > 64) throw ArgumentError('Keys > 64 are not supported');
    _key = Uint8List.fromList(key);

    _keyLength = key.length;
    _buffer!.setAll(0, key);
    _bufferPos = _blockSize;
  }
  init();
}