Skip to content

Function: sha256() ​

sha256(message): Buffer

Compute the SHA-256 digest of a string, read as UTF-8.

Parameters ​

message ​

string

The text to hash; the empty string has a digest too.

Returns ​

Buffer

The 32-byte digest, as a Buffer: call .toString('hex') or .toString('base64') for its text form.

Example ​

typescript
import {sha256} from 'lakutata/utils'

console.log(sha256('hello').toString('hex'))
//2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824

Released under the MIT License.