Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

simple-encryptor

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simple-encryptor - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

2

package.json
{
"name": "simple-encryptor",
"version": "1.0.3",
"version": "1.0.4",
"description": "Simplified encryption/decryption for node.js",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -9,3 +9,5 @@ # simple-encryptor

npm install simple-encryptor --save
```sh
npm install simple-encryptor --save
```

@@ -15,40 +17,50 @@ # Usage

// Specify a string key:
// Don't do this though, your keys should most likely be stored in env variables
// and accessed via process.env.MY_SECRET_KEY
var key = 'real secret keys should be long and random';
```js
// Specify a string key:
// Don't do this though, your keys should most likely be stored in env variables
// and accessed via process.env.MY_SECRET_KEY
var key = 'real secret keys should be long and random';
// Create an encryptor:
var encryptor = require('simple-encryptor')(key);
// Create an encryptor:
var encryptor = require('simple-encryptor')(key);
```
To encrypt something:
var encrypted = encryptor.encrypt('testing');
// Should print gibberish:
console.log('encrypted: %s', encrypted);
```js
var encrypted = encryptor.encrypt('testing');
// Should print gibberish:
console.log('encrypted: %s', encrypted);
```
To decrypt it:
var decrypted = encryptor.decrypt(encrypted);
// Should print 'testing'
console.log('decrypted: %s', decrypted);
```js
var decrypted = encryptor.decrypt(encrypted);
// Should print 'testing'
console.log('decrypted: %s', decrypted);
```
To generate an HMAC:
var myHmac = encryptor.hmac('testing');
```js
var myHmac = encryptor.hmac('testing');
```
Encrypt/decrypt an object (not just a string!):
// nested object:
var obj = {
foo: {
bar: [1, "baz"]
}
};
var objEnc = encryptor.encrypt(obj);
// Should print gibberish:
console.log('obj encrypted: %s', objEnc);
var objDec = encryptor.decrypt(objEnc);
// Should print: {"foo":{"bar":[1,"baz"]}}
console.log('obj decrypted: %j', objDec);
```js
// nested object:
var obj = {
foo: {
bar: [1, "baz"]
}
};
var objEnc = encryptor.encrypt(obj);
// Should print gibberish:
console.log('obj encrypted: %s', objEnc);
var objDec = encryptor.decrypt(objEnc);
// Should print: {"foo":{"bar":[1,"baz"]}}
console.log('obj decrypted: %j', objDec);
```

@@ -80,4 +92,6 @@ # Features

// Don't hard code keys! They should be in environment variables!
var encryptor = require('simple-encryptor')('my secret key');
```js
// Don't hard code keys! They should be in environment variables!
var encryptor = require('simple-encryptor')('my secret key');
```

@@ -93,8 +107,10 @@ ## Options hash - `encryptor(opts)`

// Don't hard code keys! They should be in environment variables!
var encryptor = require('simple-encryptor')({
key: 'my secret key',
hmac: false,
debug: true
});
```js
// Don't hard code keys! They should be in environment variables!
var encryptor = require('simple-encryptor')({
key: 'my secret key',
hmac: false,
debug: true
});
```

@@ -107,3 +123,5 @@ # Internals

$ echo "$(< /dev/urandom tr -dc A-Za-z0-9 | head -c 32)"
```sh
$ echo "$(< /dev/urandom tr -dc A-Za-z0-9 | head -c 32)"
```

@@ -110,0 +128,0 @@ # Dependencies

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc