sha512md

1.0.0 • Public • Published

sha512md

Table of Contents

Name

sha512md -- Compute SHA-512 message digests

Synopsis

const sha512 = require('sha512md')
 
let sha512md = sha512.digest(message)

The input message must be a sequence of bytes represented as an array of BigInt with values in the range 0x00n through 0xffn.

sha512.digest() returns the 512-bit SHA-512 message digest of the input message as a 512-bit BigInt value.

Description

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.

Installation

sha512md is a Node.js module available through NPM.

Before installing, download and install Node.js.

To install, use the npm install command:

$ npm install sha512md

Example

Given a sample input message, for example, in this case a simple ASCII string:

let messageString = 'The biggest obstacle to creativity is ' +
  'breaking through the barrier of disbelief.  --Rodney Mullen'

the input must be converted into an array of BigInt, e. g.:

let message = messageString.split('').map(i => BigInt(i.charCodeAt(0)))

Calling sha512.digest(message) on this message returns the 512-bit SHA-512 message digest of the input message as a 512-bit BigInt:

let digest = sha512.digest(message)

which can be, for example, converted to a printable form in hexadecimal:

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

Tests

A test.js script is included for simple testing which may be run with npm test.

See Also

OpenSSL

Standards

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.

Bugs

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

Readme

Keywords

Package Sidebar

Install

npm i sha512md

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

16.2 kB

Total Files

5

Last publish

Collaborators

  • powerpcg5