Products · Dash API

Crypto

Work out hashes and HMAC signatures, and make random bytes and UUIDs.

dash.crypto.sha256

TypeScript
dash.crypto.sha256(data: CryptoInput, options?: CryptoOutputOptions, callOptions?: CallOptions): DashRequest<string>

The SHA-256 hash of data, in hex unless you ask for { as: 'base64' }. Pass text, or { base64 } for binary data such as a file's contents.

Types: CryptoInput, CryptoOutputOptions

dash.crypto.sha512

TypeScript
dash.crypto.sha512(data: CryptoInput, options?: CryptoOutputOptions, callOptions?: CallOptions): DashRequest<string>

The SHA-512 hash of data, in hex unless you ask for { as: 'base64' }. Pass text, or { base64 } for binary data.

Types: CryptoInput, CryptoOutputOptions

dash.crypto.hmac

TypeScript
dash.crypto.hmac(options: HmacOptions, callOptions?: CallOptions): DashRequest<string>

Signs data with key, as HMAC-SHA256 or HMAC-SHA512, such as hmac({ algorithm: 'sha256', key, data }).

Types: HmacOptions

dash.crypto.randomBytes

TypeScript
dash.crypto.randomBytes(count: number, options?: CryptoOutputOptions, callOptions?: CallOptions): DashRequest<string>

count secure random bytes, from 1 to 1024.

Types: CryptoOutputOptions

dash.crypto.randomUUID

TypeScript
dash.crypto.randomUUID(callOptions?: CallOptions): DashRequest<string>

A random version 4 UUID, such as "3f0e5c3a-6d1b-4c8e-9a2f-1b7d4e6a9c05".

Types

CryptoInput

Text is read as UTF-8. Binary data, such as a file's contents, comes as base64.

TypeScript
type CryptoInput = string | { base64: string };

CryptoOutputOptions

Hex by default.

FieldTypeWhat it is
as (optional)'hex' | 'base64'

HmacAlgorithm

TypeScript
type HmacAlgorithm = 'sha256' | 'sha512';

HmacOptions

Also has the fields of CryptoOutputOptions.

FieldTypeWhat it is
algorithmHmacAlgorithm
keyCryptoInput
dataCryptoInput

Keep reading