# cyphering

> plug and play cyphering system for Javascript

Latest version **1.0.6** (published 2020-08-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install cyphering
pnpm add cyphering
yarn add cyphering
bun add cyphering
```

## 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.0.6 |
| Published | 2020-08-27 |
| First published | 2020-08-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 7.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Amir Hatami Hardoroudi |
| Maintainers | amir2550 |
| Keywords | cyphering, encryption, decryption, privateKeyGenerator, publicKeyGenerator |

## Links

- npm: https://www.npmjs.com/package/cyphering
- Repository: https://github.com/day2daychallenge/cyphering
- Homepage: https://github.com/day2daychallenge/cyphering#readme
- Issues: https://github.com/day2daychallenge/cyphering/issues
- npm.io page: https://npm.io/package/cyphering

## Dependencies (1)

- [crypto](https://npm.io/package/crypto.md) ^1.0.1

## Alternatives

- [@gemini-wallet/core](https://npm.io/package/@gemini-wallet/core.md) — 515.6K weekly downloads
- [utility](https://npm.io/package/utility.md) — 416.6K weekly downloads
- [@primno/dpapi](https://npm.io/package/@primno/dpapi.md) — 7.2K weekly downloads
- [pi-readseek](https://npm.io/package/pi-readseek.md) — 3.7K weekly downloads
- [@emilia-protocol/verify](https://npm.io/package/@emilia-protocol/verify.md) — 1.1K weekly downloads

## Recent versions

- 1.0.6 (latest) — 2020-08-27
- 1.0.5 — 2020-08-27
- 1.0.4 — 2020-08-26
- 1.0.3 — 2020-08-26

## README

# Cyphering

plug and play cyphering system for Javascript

## Note

This library was developed to make it easy for developer to create public and private key and store it easily. It is also easy to use utility to encrypt or decrypt your message message. My main objective was solve common issues which developer might face for working with `crypto` package. You can save the public key and private key or encrypt or decrypt your data by using this package. 

## Usage

In order to generate public key and private key or encrypt and decrypt a message, please follow below steps:

At the root of your project, do:

```javascript
npm install cyphering  --save
```

Then in your project:

```javascript
const Cyphering = require('cyphering');
```

## Methods

All the methods return promise.

#### Generate Public and Private keys Method:

This functionality is used for generating public and private key. it works Async. The output of this function will be json parameter which is contain your `public key and private key`. Please don't forget to store your `passPhrase` since you need it for decryption process.

###### Function:
```javascript
Cyphering.generatePublicAndPrivateKey(params)
```
###### Input:
```javascript
params: {
    "passphrase": "string"
}
````
###### Output:
```javascript
{
    "publicKey": "string",
    "privateKey": "string"
}
````

#### Encryption Method:
This function is used to encrypt your 'data' by using a `public key`.  The output of this function is `encryptedData`.

###### Function:
```javascript
Cyphering.encryption(params)
```
###### Input:
```javascript
params: {
    "data": "string",
    "publicKey": "string"
}
````
###### Output:
```javascript
    "encryptedData": "string"
````
#### Decryption Method:
This function is used to decrypt the encrypted data. You need to provide your `encrypted data`, `private key` and `passPhrase` to decrypt the data. The output of this function will be `decryptedData`. 

###### Function:
```
Cyphering.decryption(params)
```
###### Input:
```javascript
params: {
    "encryptedData": "string",
    "privateKey": "string",
    "passphrase": "string"
}
````
###### Output:
```javascript
    "decryptedData": "string"    
````


### Error codes
The error codes are the standard error codes as returned by crypto library.

### Example

```javascript
const Cyphering = require('cyphering');

async function test() {

    try {
        const passphrase = "my passphrase";

        let params = {
            passphrase
        };

        const keys = await Cyphering.generatePublicAndPrivateKey(params);

        let data = "I love to play xbox.";

        let encryptParams = {
            data: data,
            publicKey: keys.publicKey
        }

        const encryptedData = Cyphering.encryption(encryptParams);

        let decryptParams = {
            encryptedData: encryptedData,
            privateKey: keys.privateKey,
            passphrase: passphrase
        };

        const decryptedData = Cyphering.decryption(decryptParams);

        console.log('Your initial message was: ' + data);
        console.log('Your encrypted message was: ' + encryptedData);
        console.log('Your decrypted message is: ' + decryptedData);
    } catch (err) {
        console.log(err);
    }
}

test();


```

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