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

json.crypt

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json.crypt - npm Package Compare versions

Comparing version 0.2.2 to 0.2.3

23

index.js

@@ -13,12 +13,13 @@ /* jslint node: true */

JSON.cryptPassword = 'none';
JSON.cryptAlgorithm = 'aes-256-ctr';
JSON.cryptPassword = crypto.randomBytes(32);
JSON.cryptAlgorithm = 'AES-256-CBC';
JSON.encrypt = function(data,password,algorithm){
JSON.encrypt = function(data, password, algorithm){
password = password || JSON.cryptPassword;
algorithm = algorithm || JSON.cryptAlgorithm;
var iv = new Buffer(crypto.randomBytes(16));
try {
data = JSON.decycled(data);
var cipher = crypto.createCipher(algorithm,password);
data = cipher.update(data,'utf8','hex');
var cipher = crypto.createCipheriv(algorithm, password, iv);
data = cipher.update(data, 'utf8', 'hex');
data += cipher.final('hex');

@@ -29,12 +30,14 @@ } catch(error){

}
return data;
return iv.toString('hex') + ':' + data;
};
JSON.decrypt = function(data,password,algorithm){
data = data || '';
JSON.decrypt = function(data, password, algorithm){
data = (data || '').split(':');
var iv = new Buffer(data[0], 'hex');
data = data[1];
password = password || JSON.cryptPassword;
algorithm = algorithm || JSON.cryptAlgorithm;
var decipher = crypto.createDecipher(algorithm,password);
var decipher = crypto.createDecipheriv(algorithm, password, iv);
try {
data = decipher.update(data,'hex','utf8');
data = decipher.update(data, 'hex', 'utf8');
data += decipher.final('utf8');

@@ -41,0 +44,0 @@ data = JSON.revive(data);

{
"name": "json.crypt",
"description": "Javascript object encryt utility for Node.js",
"version": "0.2.2",
"version": "0.2.3",
"author": {

@@ -6,0 +6,0 @@ "name": "Bifuer",

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