decodeOid static method

String? decodeOid({
  1. required List<int> contentData,
})

Decode DER OID bytes to String with dot notation

Implementation

static String? decodeOid({required List<int> contentData}) {
  if (contentData.isEmpty) {
    return null;
  }

  var oid = "";

  var first = contentData.removeAt(0);
  oid += "${(first / 40).truncate()}.${first % 40}";

  var t = 0;
  while (contentData.length > 0) {
    var n = contentData.removeAt(0);
    t = (t << 7) | (n & 0x7F);
    if ((n & 0x80) == 0) {
      oid += ".$t";
      t = 0;
    }
  }
  return oid;
}