Created
May 24, 2019 20:51
-
-
Save max-mapper/7b8722939a83dea1fb8374a43dcb322f to your computer and use it in GitHub Desktop.
ed25519 private and public keys to pem
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { composePrivateKey, composePublicKey } from 'crypto-key-composer' | |
function privateToPem(privateKey) { | |
var decomposed = { | |
format: 'pkcs8-pem', | |
keyAlgorithm: { id: 'ed25519' }, | |
keyData: { | |
seed: privateKey, | |
}, | |
} | |
return composePrivateKey(decomposed) | |
} | |
function publicToPem(publicKey) { | |
var decomposed = { | |
format: 'spki-pem', | |
keyAlgorithm: { id: 'ed25519' }, | |
keyData: { | |
bytes: publicKey, | |
}, | |
} | |
return composePublicKey(decomposed) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment