Open kabaluyot opened 2 years ago
Many cryptography standards use ASN.1 to define their data structures, and Distinguished Encoding Rules (DER) to serialize those structures.[2] Because DER produces binary output, it can be challenging to transmit the resulting files through systems, like electronic mail, that only support ASCII.
The PEM format solves this problem by encoding the binary data using base64. PEM also defines a one-line header, consisting of -----BEGIN, a label, and -----, and a one-line footer, consisting of -----END, a label, and -----. The label determines the type of message encoded. Common labels include CERTIFICATE, CERTIFICATE REQUEST, PRIVATE KEY and X509 CRL.
As this said, the PEM =
-----BEGIN PRIVATE KEY-----
`base64(key.toDER())`
-----END PRIVATE KEY-----
(pseudocode, I believe you can write this in dart easily)
Sorry I'm not too familiar with cryptography. Any chance you can post an example?
var ec = getSecp256k1(); var priv = ec.generatePrivateKey(); var pub = priv.publicKey;
How to convert to pem format?