hrpExpand static method

List<int> hrpExpand(
  1. String hrp
)

Expands the human-readable part into the values the checksum is computed over, per spec: high bits of every character, a zero separator, then low bits of every character.

Implementation

static List<int> hrpExpand(String hrp) {
  final expand = List<int>.filled(hrp.length * 2 + 1, 0);
  for (var i = 0; i < hrp.length; i++) {
    expand[i] = hrp.codeUnitAt(i) >> 5;
  }
  // expand[hrp.length] stays 0 - the separator.
  for (var i = 0; i < hrp.length; i++) {
    expand[hrp.length + 1 + i] = hrp.codeUnitAt(i) & 0x1f;
  }
  return expand;
}