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

js-md5

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-md5

A simple MD5 hash function for JavaScript supports UTF-8 encoding.

  • 0.8.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is js-md5?

The js-md5 npm package is a lightweight JavaScript library used to generate MD5 hashes. It is commonly used for hashing strings, files, and other data types to ensure data integrity, create unique identifiers, and for cryptographic purposes.

What are js-md5's main functionalities?

Hashing a String

This feature allows you to generate an MD5 hash from a given string. The code sample demonstrates how to hash the string 'Hello, World!' and output the resulting hash.

const md5 = require('js-md5');
const hash = md5('Hello, World!');
console.log(hash); // Outputs: '65a8e27d8879283831b664bd8b7f0ad4'

Hashing a File

This feature allows you to generate an MD5 hash from a file. The code sample demonstrates how to read a file into a buffer and then hash its contents.

const md5 = require('js-md5');
const fs = require('fs');
const fileBuffer = fs.readFileSync('path/to/file.txt');
const hash = md5(fileBuffer);
console.log(hash);

Hashing an ArrayBuffer

This feature allows you to generate an MD5 hash from an ArrayBuffer. The code sample demonstrates how to create an ArrayBuffer, populate it with data, and then hash its contents.

const md5 = require('js-md5');
const buffer = new ArrayBuffer(8);
const view = new Uint8Array(buffer);
view[0] = 0x01;
view[1] = 0x02;
const hash = md5(buffer);
console.log(hash);

Other packages similar to js-md5

Keywords

FAQs

Package last updated on 09 Oct 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