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

ft-encryption

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ft-encryption - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

14

lib/encryption.js

@@ -31,2 +31,3 @@ 'use strict';

* @return {Object} object
* @throws {Error} If can't decrypt or parse JSON
*/

@@ -36,13 +37,8 @@ Encryption.prototype.decrypt = function (encrypted) {

let result = null;
try {
let str = cipher.update(encrypted, 'base64', 'utf8');
str += cipher.final('utf8');
result = JSON.parse(str);
} catch (error) {
logger.warn('Error decrypting string', {encrypted: encrypted, error: error});
} finally {
return result;
}
let str = cipher.update(encrypted, 'base64', 'utf8');
str += cipher.final('utf8');
result = JSON.parse(str);
return result;
};
module.exports = Encryption;
{
"name": "ft-encryption",
"version": "1.0.0",
"version": "1.0.1",
"description": "encryption wrapper",

@@ -5,0 +5,0 @@ "main": "lib/encryption.js",

@@ -25,7 +25,15 @@ 'use strict';

it('should return null if unable to decrypt', () => {
let data = encryption.decrypt('not an encrypted string..');
assert.ok(!data);
it('should throw error if unable to decrypt', () => {
assert.throws(() => {
let data = encryption.decrypt('not an encrypted string..');
}, Error);
});
it('should throw error if unable to parse JSON', () => {
let encrypted_string = '8SoHFEIOqSqtF13iVznL5A==';
assert.throws(() => {
let data = encryption.decrypt(encrypted_string);
}, Error);
});
});
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