appc-security
Advanced tools
Comparing version 0.0.3 to 0.0.4
10
index.js
@@ -115,6 +115,4 @@ /** | ||
// encrypt the plainText | ||
cipher.setEncoding('hex'); | ||
cipher.write(plainText); | ||
cipher.end(); | ||
var encrypted = cipher.read(); | ||
var encrypted = cipher.update(plainText,'utf-8','hex'); | ||
encrypted += cipher.final('hex'); | ||
@@ -237,4 +235,4 @@ // create an HMAC of the encrypted value + the saltAndPepper + the iv | ||
cipher.update(encrypted,'hex','utf8'); | ||
return cipher.final('utf8'); | ||
var decrypted = cipher.update(encrypted,'hex','utf-8'); | ||
return decrypted + cipher.final('utf-8'); | ||
} | ||
@@ -241,0 +239,0 @@ catch (E) { |
{ | ||
"name": "appc-security", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "Appcelerator Security Best Practices Library for Node", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -153,2 +153,16 @@ var should = require('should'), | ||
it('should encrypt json string', function(){ | ||
var key = lib.generateLargeRandomValue(), | ||
pepper = lib.generateLargeRandomValue(), | ||
hmacKey = lib.generateLargeRandomValue(), | ||
json = JSON.stringify({user:'foo',org:'bar'}), | ||
result = lib.encrypt(json,key,pepper,hmacKey); | ||
should(result).be.object; | ||
should(result.value).not.match(/=$/); | ||
var result2 = lib.decrypt(result.value,key,pepper,hmacKey); | ||
should(result2).be.string; | ||
should(result2).equal(json); | ||
}); | ||
it('should encrypt fail with invalid encoding', function(){ | ||
@@ -155,0 +169,0 @@ var key = lib.generateLargeRandomValue(), |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
26005
547