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

js-sha1

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-sha1

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

  • 0.7.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
176K
increased by9.67%
Maintainers
1
Weekly downloads
 
Created

What is js-sha1?

The js-sha1 npm package is a JavaScript implementation of the SHA-1 hash function. It allows you to generate SHA-1 hashes from strings, arrays, and array buffers. This package is useful for cryptographic operations, data integrity checks, and other scenarios where SHA-1 hashing is required.

What are js-sha1's main functionalities?

Hashing a String

This feature allows you to generate a SHA-1 hash from a string. The code sample demonstrates how to hash the string 'Hello, World!' and print the resulting hash.

const sha1 = require('js-sha1');
const hash = sha1('Hello, World!');
console.log(hash); // '943a702d06f34599aee1f8da8ef9f7296031d699'

Hashing an Array

This feature allows you to generate a SHA-1 hash from an array of bytes. The code sample demonstrates how to hash the array [0x61, 0x62, 0x63] and print the resulting hash.

const sha1 = require('js-sha1');
const hash = sha1([0x61, 0x62, 0x63]);
console.log(hash); // 'a9993e364706816aba3e25717850c26c9cd0d89d'

Hashing an ArrayBuffer

This feature allows you to generate a SHA-1 hash from an ArrayBuffer. The code sample demonstrates how to hash an ArrayBuffer containing the bytes [0x61, 0x62, 0x63] and print the resulting hash.

const sha1 = require('js-sha1');
const buffer = new ArrayBuffer(3);
const view = new Uint8Array(buffer);
view[0] = 0x61;
view[1] = 0x62;
view[2] = 0x63;
const hash = sha1(buffer);
console.log(hash); // 'a9993e364706816aba3e25717850c26c9cd0d89d'

Other packages similar to js-sha1

Keywords

FAQs

Package last updated on 24 Jan 2024

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