New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

krypt

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

krypt - npm Package Compare versions

Comparing version 0.4.0 to 0.5.0

11

CHANGELOG.md

@@ -7,3 +7,3 @@ ## 0.1.0 (3/7/2014)

+ Updated defaults for key lenght / stretching iterations
+ Updated defaults for key length / stretching iterations
+ Enhanced the output to be portable across future versions of Krypt

@@ -30,1 +30,10 @@

+ `encrypt` and `decrypt` will automatically choose async or sync based on the presence of a callback.
## 0.5.0 (2/25/2018)
+ Support for Node 6+
+ Dropping official support for Node 0.12
+ Added support for configuring the digest
+ Updated defaults
+ sha512
+ 128,000 iterations

14

Gruntfile.js

@@ -19,3 +19,3 @@ 'use strict';

mochacov: {
mochacli: {
unit: {

@@ -26,8 +26,2 @@ options: {

},
coverage: {
options: {
reporter: 'mocha-term-cov-reporter',
coverage: true
}
},
options: {

@@ -42,9 +36,9 @@ files: 'test/**/*.js',

grunt.loadNpmTasks('grunt-mocha-cov');
grunt.loadNpmTasks('grunt-mocha-cli');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.registerTask('test', ['jshint', 'mochacov:unit', 'mochacov:coverage']);
grunt.registerTask('travis', ['jshint', 'mochacov:unit', 'mochacov:coverage']);
grunt.registerTask('test', ['jshint', 'mochacli:unit']);
grunt.registerTask('travis', ['jshint', 'mochacli:unit']);
grunt.registerTask('default', 'test');
};

@@ -46,2 +46,7 @@ #!/usr/bin/env node

},
'digest': {
short: 'd',
describe: 'HMAC digest algorithm to use for deriving the key',
default: 'sha512'
},
'length': {

@@ -48,0 +53,0 @@ short: 'l',

@@ -14,3 +14,5 @@ /*!

DEFAULT_KEY_LENGTH = 256,
DEFAULT_ITERATIONS = 64000;
DEFAULT_ITERATIONS = 128000,
DEFAULT_DIGEST = 'sha512',
DEFAULT_DEPRECATED_DIGEST = 'sha1';

@@ -31,2 +33,3 @@

this.keyLength = config.keyLength || DEFAULT_KEY_LENGTH;
this.digest = config.digest || DEFAULT_DIGEST;
this.defaultSecret = config.secret;

@@ -36,2 +39,4 @@ this.context = config.context || {};

Krypt.prototype.DEFAULT_DIGEST = DEFAULT_DIGEST;
Krypt.prototype.DEFAULT_DEPRECATED_DIGEST = DEFAULT_DEPRECATED_DIGEST;

@@ -57,3 +62,7 @@ Krypt.prototype.setSecret = function setSecret(secret) {

Krypt.prototype.setDigest = function setDigest(digest) {
this.digest = digest;
};
Krypt.prototype.encrypt = function encrypt(input, secret, cb) {

@@ -107,2 +116,3 @@

salt: salt.toString('base64'),
digest: self.digest,
value: encryptedValue

@@ -117,3 +127,3 @@ };

if (async) {
crypto.pbkdf2(secret, salt, this.iterations, this.keyLength / 8, function (err, key) {
crypto.pbkdf2(secret, salt, this.iterations, this.keyLength / 8, this.digest, function (err, key) {
if (err) {

@@ -132,3 +142,3 @@ return cb(err);

try {
var key = crypto.pbkdf2Sync(secret, salt, this.iterations, this.keyLength / 8);
var key = crypto.pbkdf2Sync(secret, salt, this.iterations, this.keyLength / 8, this.digest);
return encryptUsingKey(key);

@@ -196,3 +206,4 @@ } catch (err) {

keyLength = input.keyLength || this.keyLength,
iterations = input.iterations || this.iterations;
iterations = input.iterations || this.iterations,
digest = input.digest || DEFAULT_DEPRECATED_DIGEST;

@@ -214,3 +225,3 @@ // Legacy check to deal with old versions that recorded key length in Bytes

if (async) {
crypto.pbkdf2(secret, salt, iterations, keyLength / 8, function (err, key) {
crypto.pbkdf2(secret, salt, iterations, keyLength / 8, digest, function (err, key) {
if (err) {

@@ -229,3 +240,3 @@ return cb(err);

try {
var key = crypto.pbkdf2Sync(secret, salt, iterations, keyLength / 8);
var key = crypto.pbkdf2Sync(secret, salt, iterations, keyLength / 8, digest);
return decryptUsingKey(key);

@@ -232,0 +243,0 @@ } catch (err) {

{
"name": "krypt",
"version": "0.4.0",
"version": "0.5.0",
"description": "Simple, secure symmetric encryption utility for Node.",

@@ -10,7 +10,7 @@ "main": "index.js",

"scripts": {
"test": "./node-modules/.bin/grunt test"
"test": "node_modules/.bin/grunt test"
},
"repository": {
"type": "git",
"url": "git://github.com/mmoulton/krypt.git"
"url": "git://github.com/meltmedia/krypt.git"
},

@@ -23,5 +23,5 @@ "keywords": [

"bugs": {
"url": "https://github.com/mmoulton/krypt/issues"
"url": "https://github.com/meltmedia/krypt/issues"
},
"homepage": "https://github.com/mmoulton/krypt",
"homepage": "https://github.com/meltmedia/krypt",
"dependencies": {

@@ -35,15 +35,6 @@ "nconf": "~0.7.1",

"grunt-contrib-jshint": "*",
"grunt-mocha-cov": "*",
"mocha-term-cov-reporter": "*",
"grunt-mocha-cli": "*",
"grunt-cli": "*",
"grunt-shell": "*"
},
"config": {
"blanket": {
"pattern": [
"krypt/lib",
"krypt/index"
]
}
}
}

@@ -58,4 +58,5 @@ Krypt: Simple, Secure, Symmetric Encryption

+ CBC
+ Key Stretching w/ PBKDF2 @ 64,000 iterations (default)
+ Key Stretching w/ PBKDF2 @ 128,000 iterations (default)
+ Random IV / encrypted value
+ Random salt / encrypted value
+ sha512 digest

@@ -17,2 +17,3 @@ var chai = require('chai'),

expect(encrypted).to.have.property('salt');
expect(encrypted).to.have.property('digest');
expect(encrypted).to.have.property('value');

@@ -28,2 +29,3 @@ done();

expect(encrypted.digest).to.equal(krypt.DEFAULT_DIGEST);
expect(decrypted).to.deep.equal(PLAIN_TEXT);

@@ -44,2 +46,23 @@ done();

it('should successfuly decrypt with the deprecated default digest', function (done) {
// Change to deprecated default
krypt.setDigest(krypt.DEFAULT_DEPRECATED_DIGEST);
var encrypted = krypt.encryptSync(PLAIN_TEXT, SECRET);
// Test and Remove the digest to ensure backwards compatibility
expect(encrypted.digest).to.equal(krypt.DEFAULT_DEPRECATED_DIGEST);
delete encrypted.digest;
expect(encrypted.digest).to.not.exist;
// Reset to the updated default digest
krypt.setDigest(krypt.DEFAULT_DIGEST);
var decrypted = krypt.decryptSync(JSON.stringify(encrypted), SECRET);
expect(decrypted).to.deep.equal(PLAIN_TEXT);
done();
});
it('should fail to encrypt a string value without input', function (done) {

@@ -152,2 +175,20 @@

it('should successfuly decrypt a JSON value with the deprecated default digest', function (done) {
krypt.setDigest(krypt.DEFAULT_DEPRECATED_DIGEST);
var encrypted = krypt.encryptSync(PLAIN_TEXT, SECRET);
// Test and Remove the digest to ensure backwards compatibility
expect(encrypted.digest).to.equal(krypt.DEFAULT_DEPRECATED_DIGEST);
delete encrypted.digest;
expect(encrypted.digest).to.not.exist;
krypt.decryptAsync(encrypted, SECRET, function(err, decrypted) {
expect(err).to.be.null;
expect(decrypted).to.deep.equal(PLAIN_TEXT);
done();
});
});
it('should fail to encrypt a string value without input', function (done) {

@@ -154,0 +195,0 @@

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