Socket
Socket
Sign inDemoInstall

des.js

Package Overview
Dependencies
2
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    des.js

DES implementation


Version published
Weekly downloads
9.5M
increased by0.32%
Maintainers
1
Install size
44.3 kB
Created
Weekly downloads
 

Package description

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

Readme

Source

DES.js

LICENSE

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.

Keywords

FAQs

Last updated on 29 May 2023

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc