getInternalDigest method Null safety

String getInternalDigest(
  1. String secret,
  2. int counter,
  3. int length,
  4. Hash mac
)

Mostly used for testing purposes, but this can get you the internal digest based on your settings. No handholding for this function, so you need to know exactly what to pass in.

Implementation

static String getInternalDigest(
    String secret, int counter, int length, Hash mac) {
  length = (length > 0) ? length : 6;

  final secretList = base32.decode(secret);
  final timebytes = _int2bytes(counter);

  final hmac = Hmac(mac, secretList);
  final digest = hmac.convert(timebytes).bytes;

  return _hexEncode(Uint8List.fromList(digest));
}