SHA-512 message digest
npm install sha512md- Name
- Synopsis
- Description
- Installation
- Example
- Tests
- See Also
- Standards
- Bugs
sha512md -- Compute SHA-512 message digests
``js
const sha512 = require('sha512md')
let sha512md = sha512.digest(message)
`
The input message must be a sequence of bytes represented as an array ofBigInt with values in the range 0x00n through 0xffn.
sha512.digest() returns the 512-bit SHA-512 message digest of the inputBigInt
message as a 512-bit value.
sha512md computes for an input message with an arbitrary number of bytes the
512-bit SHA-512 message digest defined by *FIPS PUB 180-4: Secure Hash
Standard*. This
module implements verbatim the version of the algorithm described in the August
2015 revision of this document. SHA-512 is the most secure of the SHA-2
family of cryptographic hash functions
and is particularly well suited for computation on modern 64-bit processors.
sha512md is a Node.js module available through
NPM.
Before installing, download and install Node.js.
To install, use the npm
install
command:
`sh`
$ npm install sha512md
Given a sample input message, for example, in this case a simple ASCII string:
`js`
let messageString = 'The biggest obstacle to creativity is ' +
'breaking through the barrier of disbelief. --Rodney Mullen'BigInt
the input must be converted into an array of , e. g.:`js`
let message = messageString.split('').map(i => BigInt(i.charCodeAt(0)))
Calling sha512.digest(message) on this message returns the 512-bit SHA-512BigInt
message digest of the input message as a 512-bit :`js`
let digest = sha512.digest(message)`
which can be, for example, converted to a printable form in hexadecimal:js`
console.log('The SHA-512 message digest is:')
console.log(digest.toString(16).padStart(128, '0'))
The above prints:
``
The SHA-512 message digest is:
4db0d748852bed440ad91ae700f1c7512889670c4968925df9aafdabaa23e1ecb4496a04075e87c42432c6f67df464c2ebedea808f5d53cda136f5fd8371ec58
A test.js script is included for simple testing which may be run with npm
test.
SHA-512 is defined by FIPS 180-4: Secure Hash Standard (August
2015).
More information on secure hash functions can be found on the CSRC Hash
Functions site maintained by
the NIST.
SHA-512 (and the SHA-2 family of cryptographic hash functions whereof it is a
part) is intended to be superseded by *FIPS 202: SHA-3 Standard:
Permutation-based Hash and Extendable-output
Functions*.
However, the SHA-512 message digest is still widely used.
The requirement for the input message to be in the form of an array of BigInt`
is unwieldy for large inputs; a future implementation should allow the function
to be called iteratively on blocks of input at a time.
Last modified: Monday, 24 June 2019