# napi-crypto

> napi bindings for openssl crypto tools

Latest version **1.2.0** (published 2017-12-13) · BSD-3-Clause license · 0 weekly downloads

## Install

```sh
npm install napi-crypto
pnpm add napi-crypto
yarn add napi-crypto
bun add napi-crypto
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.0 |
| Published | 2017-12-13 |
| First published | 2017-10-23 |
| Weekly downloads | 0 |
| License | BSD-3-Clause |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | yes |
| GitHub stars | 3 |
| Author | simon-p-r |
| Maintainers | simon-p-r |
| Keywords | crypo, openssl, napi |

## Links

- npm: https://www.npmjs.com/package/napi-crypto
- Repository: https://github.com/simon-p-r/napi-crypto
- Homepage: https://github.com/simon-p-r/napi-crypto#readme
- Issues: https://github.com/simon-p-r/napi-crypto/issues
- npm.io page: https://npm.io/package/napi-crypto

## Dependencies (3)

- [bindings](https://npm.io/package/bindings.md) ^1.3.0
- [cmake-js](https://npm.io/package/cmake-js.md) ^3.6.0
- [pre-cmake-js](https://npm.io/package/pre-cmake-js.md) 0.0.5

## Recent versions

- 1.2.0 (latest) — 2017-12-13
- 1.1.1 — 2017-11-27
- 1.0.0 — 2017-10-23

## README

# napi-crypto

[![Build Status](https://travis-ci.org/simon-p-r/napi-crypto.svg?branch=master)](https://travis-ci.org/simon-p-r/napi-crypto)

[![Windows Build Status](https://img.shields.io/appveyor/ci/simon-p-r/napi-crypto/master.svg?label=windows&style=flat-square&maxAge=2592000)](https://ci.appveyor.com/project/simon-p-r/napi-crypto)
[![Current Version](https://img.shields.io/npm/v/napi-crypto.svg?maxAge=1000)](https://www.npmjs.org/package/napi-crypto)
[![dependency Status](https://img.shields.io/david/simon-p-r/napi-crypto.svg?maxAge=1000)](https://david-dm.org/simon-p-r/napi-crypto)
[![devDependency Status](https://img.shields.io/david/dev/simon-p-r/napi-crypto.svg?maxAge=1000)](https://david-dm.org/simon-p-r/napi-crypto)

This was developed against openssl library of nodejs using n-api, currently only works on Windows

# Install

```bash
$ npm install napi-crypto
```

# Usage

### NapiCrypto.createKeyPair()

Example

```js

const NapiCrypto = require('napi-crypto');

NapiCrypto.createKeyPair();
// returns object with members privateKey and publicKey, there value is a string
```

### NapiCrypto.createKeyPairAsync()

Example

```js

const NapiCrypto = require('napi-crypto');

NapiCrypto.createKeyPairAsync();

// returns a promise resolving with either an error or object with members privateKey and publicKey, each value is a string
```

### NapiCrypto.createCSR(options)

certificate - buffer of certificate
privateKey - buffer of privateKey

Example

```js

const NapiCrypto = require('napi-crypto');

const certificate = require('fs').readFileSync('cert.pem', 'utf8');
const privateKey = require('fs').readFileSync('privateKey.pem', 'utf8');
NapiCrypto.createCSR({certificate, privateKey });
// returns buffer on renewed CSR
```

### NapiCrypto.getFingerprint(cert, digest)

Cert - buffer of certificate
Digest - one of md5, sha1, sha256 or sha512 - defaults to sha1


Example

```js

const NapiCrypto = require('napi-crypto');

const cert = require('fs').readFileSync('someCert.pem', 'utf8');
NapiCrypto.getFingerprint(cert, 'sha512');
// returns fingerprint of cert
```

Todo

* improve tests
* cross-platform builds
* ci with appveyor and travis
* pre-built binaries
* publish to npm
* improve error handling 
* add async method if possible
* generate RSA, DSA and EC key pairs
* add self-sign cert method
* improve createCSR to allow generating new one and not just renwing an existing one

---
_Source: https://npm.io/package/napi-crypto · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
