npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@europeum-ebsi/key-encoder

v0.0.0

Published

Library for encoding ECDSA private keys to PEM, DER and raw hex formats

Downloads

91

Readme

EBSI Logo

EBSI Key Encoder

This library is a fork of https://www.npmjs.com/package/key-encoder.

Table of Contents

  1. Installation
  2. Getting Started
  3. Encoding Private Keys
  4. Encoding Public Keys
  5. License

Installation

npm install @europeum-ebsi/key-encoder

Getting Started

To get started, first define your key encoder and raw private/public keys.

SECP256k1 Key Encoders

import { KeyEncoder } from "@europeum-ebsi/key-encoder";
const 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.

Key Encoders w/ Custom Curves

const encoderOptions = {
  curveParameters: [1, 3, 132, 0, 10],
  privatePEMOptions: { label: "EC PRIVATE KEY" },
  publicPEMOptions: { label: "PUBLIC KEY" },
  curve: "secp256k1",
};
const keyEncoder = new KeyEncoder(encoderOptions);

Declaring Raw Keys

const rawPrivateKey =
  "844055cca13efd78ce79a4c3a4c5aba5db0ebeb7ae9d56906c03d333c5668d5b";
const rawPublicKey =
  "04147b79e9e1dd3324ceea115ff4037b6c877c73777131418bfb2b713effd0f502327b923861581bd5535eeae006765269f404f5f5c52214e9721b04aa7d040a75";

Encoding Private Keys

Encode to and from raw, PEM (encode to 'pkcs8' and 'pkcs1'), and DER formats.

Encoding Private Keys as PEMs

const pemPrivateKey = keyEncoder.encodePrivate(
  rawPrivateKey,
  "raw",
  "pem",
  "pkcs8",
); //default is 'pkcs1'

Example output:

-----BEGIN PRIVATE KEY-----
MIGNAgEAMBAGByqGSM49AgEGBSuBBAAKBHYwdAIBAQQghEBVzKE+/XjOeaTDpMWr
pdsOvreunVaQbAPTM8VmjVugBwYFK4EEAAqhRANCAAQUe3np4d0zJM7qEV/0A3ts
h3xzd3ExQYv7K3E+/9D1AjJ7kjhhWBvVU17q4AZ2Umn0BPX1xSIU6XIbBKp9BAp1
-----END PRIVATE KEY-----

Encoding Private Keys to DER Format

const derPrivateKey = keyEncoder.encodePrivate(rawPrivateKey, "raw", "der");

Example output:

30740201010420844055cca13efd78ce79a4c3a4c5aba5db0ebeb7ae9d56906c03d333c5668d5ba00706052b8104000aa14403420004147b79e9e1dd3324ceea115ff4037b6c877c73777131418bfb2b713effd0f502327b923861581bd5535eeae006765269f404f5f5c52214e9721b04aa7d040a75

Encoding Public Keys

Encode to and from raw, PEM, and DER formats.

Encoding Public Keys as PEMs

const pemPublicKey = keyEncoder.encodePublic(rawPublicKey, "raw", "pem");

Example output:

-----BEGIN PUBLIC KEY-----
MFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAEFHt56eHdMyTO6hFf9AN7bId8c3dxMUGL
+ytxPv/Q9QIye5I4YVgb1VNe6uAGdlJp9AT19cUiFOlyGwSqfQQKdQ==
-----END PUBLIC KEY-----

Encoding Public Keys to DER Format

const derPublicKey = keyEncoder.encodePublic(rawPublicKey, "raw", "der");

Example output:

3056301006072a8648ce3d020106052b8104000a03420004147b79e9e1dd3324ceea115ff4037b6c877c73777131418bfb2b713effd0f502327b923861581bd5535eeae006765269f404f5f5c52214e9721b04aa7d040a75

License

Copyright (C) 2026 European Union

This program is free software: you can redistribute it and/or modify it under the terms of the EUROPEAN UNION PUBLIC LICENCE v. 1.2 as published by the European Union.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the EUROPEAN UNION PUBLIC LICENCE v. 1.2 for further details.

You should have received a copy of the EUROPEAN UNION PUBLIC LICENCE v. 1.2. along with this program. If not, see https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12.