Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/reklatsmasters/pem-file

PEM file format encoder/decoder.
https://github.com/reklatsmasters/pem-file

crypto js node nodejs pem

Last synced: 24 days ago
JSON representation

PEM file format encoder/decoder.

Awesome Lists containing this project

README

        

# pem-file

[![Build Status](https://travis-ci.org/reklatsmasters/pem-file.svg?branch=master)](https://travis-ci.org/reklatsmasters/pem-file)
[![npm](https://img.shields.io/npm/v/pem-file.svg)](https://npmjs.org/package/pem-file)
[![node](https://img.shields.io/node/v/pem-file.svg)](https://npmjs.org/package/pem-file)
[![license](https://img.shields.io/npm/l/pem-file.svg)](https://npmjs.org/package/pem-file)
[![downloads](https://img.shields.io/npm/dm/pem-file.svg)](https://npmjs.org/package/pem-file)
[![Coverage Status](https://coveralls.io/repos/github/reklatsmasters/pem-file/badge.svg?branch=master)](https://coveralls.io/github/reklatsmasters/pem-file?branch=master)

PEM file format encoder/decoder.

## Usage

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

const file = fs.readFileSync('./pubkey.pem')
console.log(pem.decode(file)) //
```

```js
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