Hi I am doing the save private key of secp256k1 to pem file with Swift. As I generate the private key, I got a 32 bytes key, somehow in base64 it is "7vInO7T/GBg6bxkr+6W4ESV4UOy6W4E2N4i9fBgMqYM=" which is a quite short string. I see some example of other private key generated by other languages such as PHP or Scala I can see the private key in PEM file is somehow like this: -----BEGIN EC PRIVATE KEY----- MHQCAQEEIEEtespOtpvBZFfn+2YX/9WlsRLTb8YSWkfV1IBP+Lz9oAcGBSuBBAAK oUQDQgAEun8ex7Yei3nN1mnw2/c9QNwIEzAZ8+upXkN5hgHNgrpn2ufxP8G/byc9 Lx8wKQIXhmCIXMySxUeQUCDzl65trA== -----END EC PRIVATE KEY----- Which is a very long string of base64. How can I generate such long string and what the rule for it? I mean what should I do to make my quite short base64 string that I can generate to such long string as other languages do?
Asked
Active
Viewed 311 times
0
-
Why do you want the output in one format or another? There are unfortunately multiple formats for private keys. – President James K. Polk Feb 28 '22 at 01:44
-
I have the task of importing the key from PEM file and save the key to PEM file. I have sereral examples of the PEM file generated from other languages and I am trying to figure out how to generate such string like them in Swift. – nguyen tien Feb 28 '22 at 05:16