sha

Bun

Symbol

sha

function sha(input: StringOrBuffer, hashInto?: TypedArray<ArrayBufferLike>): TypedArray
@param input

string, Uint8Array, or ArrayBuffer to hash. Uint8Array or ArrayBuffer will be faster

@param hashInto

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

This hashing function balances speed with cryptographic strength. This 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
function sha(input: StringOrBuffer, encoding: DigestEncoding): string
@param input

string, Uint8Array, or ArrayBuffer to hash. Uint8Array or ArrayBuffer will be faster

@param encoding

DigestEncoding to return the hash in

This hashing function balances speed with cryptographic strength. This 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

Referenced types

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