Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
key-encoder
Advanced tools
Readme
$ npm install key-encoder
To get started, first define your key encoder and raw private/public keys.
var KeyEncoder = require('key-encoder'),
keyEncoder = new KeyEncoder('secp256k1')
As shown above, there is built in support for SECP256k1 (the curve Bitcoin uses), but you can pass in your own curve parameters for any curve you'd like.
var EC = require('elliptic').ec
var encoderOptions = {
curveParameters: [1, 3, 132, 0, 10],
privatePEMOptions: {label: 'EC PRIVATE KEY'},
publicPEMOptions: {label: 'PUBLIC KEY'},
curve: new EC('secp256k1')
}
var keyEncoder = new KeyEncoder(encoderOptions)
var rawPrivateKey = '844055cca13efd78ce79a4c3a4c5aba5db0ebeb7ae9d56906c03d333c5668d5b',
rawPublicKey = '04147b79e9e1dd3324ceea115ff4037b6c877c73777131418bfb2b713effd0f502327b923861581bd5535eeae006765269f404f5f5c52214e9721b04aa7d040a75'
Encode to and from raw, PEM, and DER formats.
var pemPrivateKey = keyEncoder.encodePrivate(rawPrivateKey, 'raw', 'pem')
Example output:
-----BEGIN EC PRIVATE KEY-----
MHQCAQEEIIRAVcyhPv14znmkw6TFq6XbDr63rp1WkGwD0zPFZo1boAcGBSuBBAAK
oUQDQgAEFHt56eHdMyTO6hFf9AN7bId8c3dxMUGL+ytxPv/Q9QIye5I4YVgb1VNe
6uAGdlJp9AT19cUiFOlyGwSqfQQKdQ==
-----END EC PRIVATE KEY-----
var derPrivateKey = keyEncoder.encodePrivate(rawPrivateKey, 'raw', 'der')
Example output:
30740201010420844055cca13efd78ce79a4c3a4c5aba5db0ebeb7ae9d56906c03d333c5668d5ba00706052b8104000aa14403420004147b79e9e1dd3324ceea115ff4037b6c877c73777131418bfb2b713effd0f502327b923861581bd5535eeae006765269f404f5f5c52214e9721b04aa7d040a75
Encode to and from raw, PEM, and DER formats.
var pemPublicKey = keyEncoder.encodePublic(rawPublicKey, 'raw', 'pem')
Example output:
-----BEGIN PUBLIC KEY-----
MFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAEFHt56eHdMyTO6hFf9AN7bId8c3dxMUGL
+ytxPv/Q9QIye5I4YVgb1VNe6uAGdlJp9AT19cUiFOlyGwSqfQQKdQ==
-----END PUBLIC KEY-----
var derPublicKey = keyEncoder.encodePublic(rawPublicKey, 'raw', 'der')
Example output:
3056301006072a8648ce3d020106052b8104000a03420004147b79e9e1dd3324ceea115ff4037b6c877c73777131418bfb2b713effd0f502327b923861581bd5535eeae006765269f404f5f5c52214e9721b04aa7d040a75
FAQs
Library for encoding ECDSA private keys to PEM, DER and raw hex formats
The npm package key-encoder receives a total of 20,408 weekly downloads. As such, key-encoder popularity was classified as popular.
We found that key-encoder demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.