Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
The des.js npm package is a JavaScript implementation of DES (Data Encryption Standard) and Triple DES (3DES) encryption algorithms. It allows for the encryption and decryption of data using these symmetric-key algorithms.
DES Encryption
This code sample demonstrates how to encrypt a message using DES in ECB mode. The 'des.js' package provides the DES class which can be used to create an encryption object with a specified key.
const DES = require('des.js');
const crypto = require('crypto');
const key = new Buffer('0123456789abcd0123456789', 'hex');
const desEcb = new DES.DES({ type: 'encrypt', key: key });
const message = 'secret message';
const msgBuffer = new Buffer(message);
const encrypted = desEcb.update(msgBuffer).concat(desEcb.final());
console.log(encrypted.toString('hex'));
DES Decryption
This code sample demonstrates how to decrypt a message that was previously encrypted using DES in ECB mode. The 'des.js' package provides the DES class which can be used to create a decryption object with a specified key.
const DES = require('des.js');
const crypto = require('crypto');
const key = new Buffer('0123456789abcd0123456789', 'hex');
const desEcb = new DES.DES({ type: 'decrypt', key: key });
const encryptedMessage = 'e5c9b9e91b1b5fc5600f1ec6b64b2c57';
const encryptedBuffer = new Buffer(encryptedMessage, 'hex');
const decrypted = desEcb.update(encryptedBuffer).concat(desEcb.final());
console.log(decrypted.toString('utf8'));
3DES Encryption
This code sample demonstrates how to encrypt a message using Triple DES (3DES) in EDE mode. The 'des.js' package provides the DESede class which can be used to create an encryption object with a specified key for 3DES encryption.
const DES = require('des.js');
const crypto = require('crypto');
const key = new Buffer('0123456789abcdef0123456789abcdef0123456789abcdef', 'hex');
const desEde = new DES.DESede({ type: 'encrypt', key: key });
const message = 'secret message';
const msgBuffer = new Buffer(message);
const encrypted = desEde.update(msgBuffer).concat(desEde.final());
console.log(encrypted.toString('hex'));
3DES Decryption
This code sample demonstrates how to decrypt a message that was previously encrypted using Triple DES (3DES) in EDE mode. The 'des.js' package provides the DESede class which can be used to create a decryption object with a specified key for 3DES decryption.
const DES = require('des.js');
const crypto = require('crypto');
const key = new Buffer('0123456789abcdef0123456789abcdef0123456789abcdef', 'hex');
const desEde = new DES.DESede({ type: 'decrypt', key: key });
const encryptedMessage = 'a1b2c3d4e5f67890a1b2c3d4e5f67890';
const encryptedBuffer = new Buffer(encryptedMessage, 'hex');
const decrypted = desEde.update(encryptedBuffer).concat(desEde.final());
console.log(decrypted.toString('utf8'));
node-forge is a native JavaScript implementation of various network protocols and cryptography tools. It includes support for DES and 3DES, as well as other algorithms like AES and RSA. Compared to des.js, node-forge offers a broader range of cryptographic functions and protocols.
crypto-js is a collection of cryptographic algorithms implemented in JavaScript. It supports various encryption standards including DES and 3DES. While des.js focuses specifically on DES and 3DES, crypto-js provides a wider array of cryptographic algorithms like AES, SHA1, and MD5.
bcryptjs is a JavaScript implementation of the bcrypt password hashing function. Unlike des.js, which is used for encryption and decryption, bcryptjs is specifically designed for securely hashing and storing passwords. It does not provide encryption algorithms like DES or 3DES.
This software is licensed under the MIT License.
Copyright Fedor Indutny, 2015.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
DES implementation
The npm package des.js receives a total of 5,746,828 weekly downloads. As such, des.js popularity was classified as popular.
We found that des.js demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.