Skip to main content

LensStudio:Crypto.subtle

Class

Lower-level cryptographic primitives mirroring the Web Crypto SubtleCrypto interface.

Index

Methods

Example

const { subtle } = await import('LensStudio:Crypto');

const data = new TextEncoder().encode('Hello, Lens Studio!');
const hash = await subtle.digest('SHA-256', data);
const hex = Array.from(hash, (b: number) => b.toString(16).padStart(2, '0')).join('');
console.log(`SHA-256 (${hash.length} bytes): ${hex.slice(0, 16)}...`);

Methods

digest()

static digest(algorithm, data): Promise<Uint8Array<ArrayBufferLike>>

Computes a cryptographic hash of the given data using the specified algorithm and returns the resulting digest.

Parameters

ParameterType
algorithmstring
dataUint8Array

Returns

Promise<Uint8Array<ArrayBufferLike>>