lengthTo16Bytes function

String lengthTo16Bytes(
  1. int length
)

Implementation

String lengthTo16Bytes(int length) {
  /// The hex must be divisible by 16 without remainder. If this is not the case, then zeros are inserted to the right until the value is divisible by
  /// 16. This is important for the Poly1305 because it consists of four elements of a block.
  String lengthHex =
      int.parse((length / 2).toStringAsFixed(0)).toRadixString(16);
  lengthHex = isNotEven(lengthHex);
  if ((lengthHex.length % 16) != 0) {
    lengthHex = lengthHex.padRight(16 * (lengthHex.length / 16).ceil(), "0");
  }

  return lengthHex;
}