getEncoded method
Returns the DER representation selected by preferPkcs1, encoded as text
using the binary encoding named by encoding. The DER-selection rules are
the same as for GetDer.
Common encoding valueOutput encoding
| base64 | | Standard Base64 with no line breaks. This is the most
common choice for textual DER. |
| base64Url | | URL-safe Base64, useful when key bytes must appear in
URLs or JSON-oriented protocols. |
| hex | | Uppercase hexadecimal. |
| hexLower | | Lowercase hexadecimal. |
Encoding names are case-insensitive. See the Chilkat Binary Encoding List for the complete set of supported encoding names. An empty or unsupported encoding name causes the method to fail. The method also fails if this object is empty.
Throws a ChilkatException if the call fails; the details are in ChilkatException.lastErrorText. Throws an ArgumentError if a string argument contains a NUL character.
Implementation
String getEncoded(bool preferPkcs1, String encoding) {
final h = _handle;
return using((arena) {
final r = _CkPublicKey_GetEncoded(
h,
preferPkcs1 ? 1 : 0,
_toNative(arena, encoding, 'encoding'),
);
if (r == nullptr) {
throw _fail('getEncoded');
}
return r.toDartString();
});
}