getInternalDigest static method Null safety

String getInternalDigest(
  1. String secret,
  2. int counter,
  3. int length,
  4. Hash mac,
  5. {bool isGoogle = false}
)

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,
    {bool isGoogle = false}) {
  length = (length > 0) ? length : 6;

  var secretList = Uint8List.fromList(utf8.encode(secret));
  if (isGoogle) {
    secretList = base32.decode(secret);
  }
  final timebytes = _int2bytes(counter);

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

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