toString method
Export a RSAPublic
key as String which can be reversed using RSAPublicKey.fromString.
Implementation
@override
String toString() {
final algorithmSeq = ASN1Sequence();
final algorithmAsn1Obj = ASN1Object.fromBytes(Uint8List.fromList(
[0x6, 0x9, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0xd, 0x1, 0x1, 0x1]));
final paramsAsn1Obj = ASN1Object.fromBytes(Uint8List.fromList([0x5, 0x0]));
algorithmSeq.add(algorithmAsn1Obj);
algorithmSeq.add(paramsAsn1Obj);
final publicKeySeq = ASN1Sequence();
publicKeySeq.add(ASN1Integer(_publicKey.modulus!));
publicKeySeq.add(ASN1Integer(_publicKey.exponent!));
final publicKeySeqBitString =
ASN1BitString(Uint8List.fromList(publicKeySeq.encodedBytes));
final topLevelSeq = ASN1Sequence();
topLevelSeq.add(algorithmSeq);
topLevelSeq.add(publicKeySeqBitString);
return base64.encode(topLevelSeq.encodedBytes);
}