hmacBlockTransformerEncrypt method

Uint8List hmacBlockTransformerEncrypt(
  1. Uint8List hmacKey,
  2. Uint8List data
)

Implementation

Uint8List hmacBlockTransformerEncrypt(Uint8List hmacKey, Uint8List data) {
  final writer = WriterHelper();
  final reader = ReaderHelper(data);
  const blockSize = 1024 * 1024;
  var blockIndex = 0;
  while (true) {
    final blockData = reader.readBytesUpTo(blockSize);
    final calculatedHash = _hmacHashForBlock(hmacKey, blockIndex, blockData);
    writer.writeBytes(calculatedHash);
    writer.writeUint32(blockData.length);
    if (blockData.isEmpty) {
//        writer.writeUint32(0);
      return writer.output.toBytes();
    }
    writer.writeBytes(blockData);
    blockIndex++;
  }
}