Implementation
static RsaPublicKey decode(String encodedKey) {
ASN1Parser topLevelParser = ASN1Parser(base64.decode(encodedKey));
ASN1Sequence topLevelSeq = topLevelParser.nextObject() as ASN1Sequence;
ASN1BitString publicKeyBitString =
topLevelSeq.elements![1] as ASN1BitString;
ASN1Sequence publicKeySeq =
ASN1Sequence.fromBytes(publicKeyBitString.stringValues as Uint8List);
ASN1Integer modulus = publicKeySeq.elements![0] as ASN1Integer;
ASN1Integer exponent = publicKeySeq.elements![1] as ASN1Integer;
return RsaPublicKey(modulus.integer!, exponent.integer!);
}