Coder Social home page Coder Social logo

hlf-dev-zm / wa-decrypt-nodejs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from open-wa/wa-decrypt-nodejs

0.0 0.0 0.0 204 KB

A lightweight implementation of the wa-automate-nodejs media decryption code for NodeJS

JavaScript 0.63% TypeScript 99.37%

wa-decrypt-nodejs's Introduction

npm version Maintainability Buy me a coffee

wa-decrypt

This is a single function library born out of the open-wa/wa-automate-nodejs project. The reason for this project is so you can easily decrypt messages on a remote process without needing to install all of the dependencies (e.g puppeteer) that come with open-wa/wa-automate-nodejs.

Installation

> npm i --save @open-wa/wa-decrypt

Decrypting Media

Here is a sample of how to decrypt media. This has been tested on images, videos, documents, audio and voice notes.

import { decryptMedia } from '@open-wa/wa-decrypt';
const mime = require('mime-types');
const fs = require('fs');

const processMessage = async message => {
    if (message.mimetype) {
      const filename = `${message.t}.${mime.extension(message.mimetype)}`;
      const mediaData = await decryptMedia(message);
      const imageBase64 = `data:${message.mimetype};base64,${mediaData.toString(
        'base64'
      )}`;
      fs.writeFile(filename, mediaData, function(err) {
        if (err) {
          return console.log(err);
        }
        console.log('The file was saved!');
      });
    }
  }

Verifying Decryption

As of v2.0.0 of wa-decrypt, you are now able to verify the decryption output hash with the actual hash of the file as represented by message.filehash. You can see an example of this in test/index.ts. Please note that YOU CANNOT VERIFY THE HASH OF STICKERS, so don't even try it right now!

import crypto from 'crypto';
...

    const mediaData = await decryptMedia(message);
    let output_hash = crypto.createHash('sha256').update(mediaData).digest('base64');
    let hashValid = message.filehash == output_hash;
    console.log('Hash Validated:', hashValid);

Troubleshooting

If you're having issues with 404s or are unable to decrypt stickers, please see this documentation:

docs.openwa.dev

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

MIT

Legal

This code is in no way affiliated with, authorized, maintained, sponsored or endorsed by WhatsApp or any of its affiliates or subsidiaries. This is an independent and unofficial software. Use at your own risk.

Cryptography Notice

This distribution includes cryptographic software. The country in which you currently reside may have restrictions on the import, possession, use, and/or re-export to another country, of encryption software. BEFORE using any encryption software, please check your country's laws, regulations and policies concerning the import, possession, or use, and re-export of encryption software, to see if this is permitted. See http://www.wassenaar.org/ for more information.

The U.S. Government Department of Commerce, Bureau of Industry and Security (BIS), has classified this software as Export Commodity Control Number (ECCN) 5D002.C.1, which includes information security software using or performing cryptographic functions with asymmetric algorithms. The form and manner of this distribution makes it eligible for export under the License Exception ENC Technology Software Unrestricted (TSU) exception (see the BIS Export Administration Regulations, Section 740.13) for both object code and source code.

wa-decrypt-nodejs's People

Contributors

dependabot-preview[bot] avatar smashah avatar dependabot[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.