getInternalDigest method

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;

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

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

  return hex.encode(digest);
}