pem-file

PEM file format encoder/decoder.

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
pem-file
1.0.14 years ago4 years agoMinified + gzip package size for pem-file in KB

Readme

pem-file
Build Status npm node license downloads Coverage Status
PEM file format encoder/decoder.

Usage

const fs = require('fs')
const pem = require('pem-file')

const file = fs.readFileSync('./pubkey.pem')
console.log(pem.decode(file)) // <Buffer 30 82 ...>

const pem = require('pem-file')
const source = Buffer.from('12345')

console.log(pem.encode(source, 'DATA'))
// Output:
// -----BEGIN DATA-----
// MTIzNDU=
// -----END DATA-----

API

  • encode(source: Buffer, label: string): string

Convert data to PEM format.
  • decode(pem: Buffer | String): Buffer

Convert PEM formatted data to raw buffer.

License

MIT, 2018 (c) Dmitriy Tsvettsikh