function

sha

function sha(
hashInto?: TypedArray<ArrayBufferLike>
): TypedArray;

Hash input using SHA-2 512/256

This hashing function balances speed with cryptographic strength. It does not encrypt or decrypt data.

The implementation uses BoringSSL (used in Chromium & Go)

The equivalent openssl command is:

# You will need OpenSSL 3 or later
openssl sha512-256 /path/to/file
@param input

string, Uint8Array, or ArrayBuffer to hash. Uint8Array or ArrayBuffer is faster

@param hashInto

optional Uint8Array to write the hash to. 32 bytes minimum.

function sha(
encoding: DigestEncoding
): string;

Hash input using SHA-2 512/256

This hashing function balances speed with cryptographic strength. It does not encrypt or decrypt data.

The implementation uses BoringSSL (used in Chromium & Go)

The equivalent openssl command is:

# You will need OpenSSL 3 or later
openssl sha512-256 /path/to/file
@param input

string, Uint8Array, or ArrayBuffer to hash. Uint8Array or ArrayBuffer is faster

@param encoding

DigestEncoding to return the hash in

Referenced types

type StringOrBuffer = string | NodeJS.TypedArray | ArrayBufferLike
type DigestEncoding =
| 'utf8'
| 'ucs2'
| 'utf16le'
| 'latin1'
| 'ascii'
| 'base64'
| 'base64url'
| 'hex'