dump method

  1. @override
String dump({
  1. int spaces = 0,
})
override

Creates a readable dump from the current ASN1Object.

Important note: Subclasses need to override this method. If the ASN1Object is constructed and has child elements, dump() has to be called for each child element.

Implementation

@override
String dump({int spaces = 0}) {
  var sb = StringBuffer();
  for (var i = 0; i < spaces; i++) {
    sb.write(' ');
  }
  if (isConstructed!) {
    sb.write('OCTET STRING (${elements!.length} elem)');
    for (var e in elements!) {
      var dump = e.dump(spaces: spaces + dumpIndent);
      sb.write('\n $dump');
    }
  } else {
    sb.write('OCTET STRING (${octets!.length} byte) ');
    for (var o in octets!) {
      var s = o.toRadixString(16).toUpperCase();
      if (s.length == 1) {
        s = '0$s';
      }
      sb.write(s);
    }
  }
  return sb.toString();
}