hash

Performs a SHA-512 hash of the input plaintext.

hashdatahash

nametypedescription

data

Message

Value wrapper for the data to be hashed.

hash

Hash

Value wrapper for the hashed data.

hash is a convenience function that exposes the TweetNaCl.js implementation of SHA-512 hashing.

Place the data to hash in an instance of Message using the Message.from class method.

hash returns an instance of Hash, which encapsulates the SHA-512 hash. You may format the value via the instance method Hash::to.

Example

import assert from "assert"
import {confidential} from "panda-confidential"
{hash, Message} = confidential()

do ->

  hashed = hash Message.from "utf8", "Hello, World!"

  assert.equal (hashed.to "base64"),
    "N015SpXNz9izWZMYX++bo2jxYNja9DLQi6nx7R5avmzGkpHg+i/gAGpSVw7xjBne9OYXwzzlLvCm5fvjGMsDhw=="