formatPkcs12Password static method

Uint8List formatPkcs12Password(
  1. Uint8List password
)

Formats the given password according to RFC 7292 Appendix B.1

Implementation

static Uint8List formatPkcs12Password(Uint8List password) {
  if (password.isNotEmpty) {
    // +1 for extra 2 pad bytes.
    var bytes = Uint8List((password.length + 1) * 2);

    for (var i = 0; i != password.length; i++) {
      bytes[i * 2] = (password[i] >>> 8);
      bytes[i * 2 + 1] = password[i];
    }

    return bytes;
  } else {
    return Uint8List(0);
  }
}