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

https://github.com/compwright/defuse-node

Unofficial Javascript port of defuse/php-encryption for Node.js
https://github.com/compwright/defuse-node

cross-platform encryption javascript php

Last synced: 6 months ago
JSON representation

Unofficial Javascript port of defuse/php-encryption for Node.js

Awesome Lists containing this project

README

          

# defuse-node

Javascript port of [defuse/php-encryption](https://github.com/defuse/php-encryption) for Node.js.

> This is an unofficial port. The creators of defuse/php-encryption recommend libsodium for cross-platform use cases. Use this library at your own risk :bangbang:

This port implements everything in the official library EXCEPT for:

* File
* Crypto.legacyDecrypt()

For a compatibility demo, see https://github.com/compwright/defuse-node-compat-demo

If you would like to contribute any missing part, feel free to open a pull request.

## Requirements

Node.js 16+ with OpenSSL

## Installation

With NPM:

```
$ npm install --save defuse-node
```

With Yarn:

```
$ yarn add defuse-node
```

## Quick Start

```javascript
import { Key, Crypto } from 'defuse-node'

const key = Key.loadFromAsciiSafeString('...')

// Encrypt
const data = 'Hello, world'
const ciphertext = Crypto.encrypt(data, key)

// Decrypt
const plaintext = Crypto.decrypt(ciphertext, key)
```

## Documentation

See https://github.com/defuse/php-encryption#getting-started

## License

MIT License