Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
sha256
Advanced tools
Readme
JavaScript component to compute the SHA256 of strings or bytes.
This library is deprecated. If you think it's important to maintain this library, please submit an issue and the case will be consider or the repo / ownership will be transferred to you. Viable alternatives:
npm install --save sha256
Note: when Node.js is detected, the Node Crypto
component is used instead of re-implementing the SHA256 hash logic.
There are two methods, one for computing the hash of the input, and one for double-hashing it:
sha256('hello'); // "2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824"
sha256.x2('hello'); // "d7914fe546b684688bb95f4f888a92dfc680603a75f23eb823658031fff766d9"
Input is either an array of bytes or a string. String are always interpreted as binary data; if you have a hex-encoded string of data to parse, first convert it to a binary string or array of bytes.
Output by default is a hexadecimal-encoded string. Other options are an array of bytes, or a binary-encoded string:
sha256('hello'); // "2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824" <= Hex-encoded; default
sha256('hello', { asBytes: true }); // [44,242,77,186,95,176,163,14,38,232,59,42,197,185,226,158,27,22,30,92,31,167,66,94,115,4,51,98,147,139,152,36] <= Array of bytes
sha256('hello', { asString: true }); // ",òMº_°£&è;*Źâ\§B^s3b$" <= Binary-encoded string
Unit tests are written in Mocha. To run the test suite, checkout the git repository, and from within the base folder run:
$ npm install --dev
$ npm test
Most of the code from CryptoJS https://code.google.com/p/crypto-js/
(MIT License)
Copyright 2013, JP Richardson jprichardson@gmail.com
FAQs
Compute SHA256 of bytes or strings.
The npm package sha256 receives a total of 38,546 weekly downloads. As such, sha256 popularity was classified as popular.
We found that sha256 demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
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.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.