encodeSshPublicKey method
Encode an RSA public key in the SSH Public Key (RFC 4716) format.
If doNotQuoteComments
, double-quotes around the comment value are not
included in the header value. Otherwise, double-quotes are included in the
value (as permitted by section 3.3.2 of RFC 4716 and is "common
practice").
Programs normally use encode
method from the PublicKeyExt extension,
with the appropriate format, which will invoke this method.
But programs will need to invoke this method directly, if they want to
omit the double-quotes.
Implementation
String encodeSshPublicKey({bool doNotQuoteComments = false}) {
// Create a list of headers from the properties
// Note: property keys are case-insensitive, but header tags retain case
final headers = <SshPublicKeyHeader>[];
final tags = properties.keys.toList()..sort();
for (final tag in tags) {
for (final value in properties.values(tag)!) {
headers.add(SshPublicKeyHeader(tag, value));
}
}
final typeExponentModulus = _encodeAsChunks();
return SshPublicKey(headers, typeExponentModulus)
.encode(doNotQuoteComments: doNotQuoteComments);
}