RsaPublicKey.fromRawBytes constructor

RsaPublicKey.fromRawBytes(
  1. Uint8List bytes
)

Creates an RsaPublicKey from raw bytes (DER encoded)

Implementation

factory RsaPublicKey.fromRawBytes(Uint8List bytes) {
  final parser = pc.ASN1Parser(bytes);
  final asn1Sequence = parser.nextObject() as pc.ASN1Sequence;
  final publicKey = RSAPublicKey(
    (asn1Sequence.elements?[0] as pc.ASN1Integer).integer!,
    (asn1Sequence.elements?[1] as pc.ASN1Integer).integer!,
  );

  return RsaPublicKey(publicKey);
}