ASN1PrintableString.fromBytes constructor

ASN1PrintableString.fromBytes(
  1. Uint8List encodedBytes
)

Creates an ASN1PrintableString entity from the given encodedBytes.

Implementation

ASN1PrintableString.fromBytes(Uint8List encodedBytes)
    : super.fromBytes(encodedBytes) {
  if (ASN1Utils.isConstructed(encodedBytes.elementAt(0))) {
    elements = [];
    var parser = ASN1Parser(valueBytes);
    var sb = StringBuffer();
    while (parser.hasNext()) {
      var printableString = parser.nextObject() as ASN1PrintableString;
      sb.write(printableString.stringValue);
      elements!.add(printableString);
    }
    stringValue = sb.toString();
  } else {
    stringValue = ascii.decode(valueBytes!);
  }
}