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

des.js

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

des.js

DES implementation

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7.4M
decreased by-22.51%
Maintainers
1
Weekly downloads
 
Created

What is des.js?

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.

What are des.js's main functionalities?

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'));

Other packages similar to des.js

Keywords

FAQs

Package last updated on 29 May 2023

Did you know?

Socket

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.

Install

Related posts

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