A utility for translating cryptographic keys between representations.
Keyto is pronounced 'key-to'.
Full project documentation is available here.
This library is currently experimental. Until v1.0.0 is released, breaking changes will only incur a minor version increment.
Translate Private PEM to Public JWK:
const keyto = require('@trust/keyto')
let pemPrivate = getPrivatePemStringSomehow()
let jwk = getPublicJwkSomehow()
// String data can either be passed in directly:
let key = keyto.from(pemPrivate, 'pem').toJwk('public')
// Or can be passed in as an object instead:
let key = keyto.from({ key: pemPrivate }, 'pem').toJwk('public')
assertEqual(jwk, key)
Translate Private Hex (Blockchain) Key to PKCS8 Public PEM:
const keyto = require('@trust/keyto')
let blk = getPrivateBlockchainHexStringSomehow()
let pemPublic = getPublicPemSomehow()
let key = keyto.from(blk, 'blk').toString('pem', 'public_pkcs8')
assertEqual(pemPublic, key)
args:
format:
Format can be any of these: 'pem', 'jwk' or 'blk'.
args:
selector:
Selector can be any of these: 'public', 'private'.
args:
format:
Format can be any of these: 'pem', 'jwk' or 'blk'.
selector:
Selector can be any of these: 'public', 'private', 'public_pkcs1', 'public_pkcs8', 'private_pkcs1' or 'private_pkcs8'.
PRs accepted.
Small note: If editing the README, please conform to the standard-readme specification.
MIT © 2017-2018 Greg Linklater