LensStudio:Crypto.subtle
ClassLower-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()
staticdigest(algorithm,data):Promise<Uint8Array<ArrayBufferLike>>
Computes a cryptographic hash of the given data using the specified algorithm and returns the resulting digest.
Parameters
| Parameter | Type |
|---|---|
algorithm | string |
data | Uint8Array |
Returns
Promise<Uint8Array<ArrayBufferLike>>