Lower-level cryptographic primitives mirroring the Web Crypto SubtleCrypto interface.
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)}...`); Copy
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)}...`);
Protected
Snap Hidden
Static
Computes a cryptographic hash of the given data using the specified algorithm and returns the resulting digest.
Lower-level cryptographic primitives mirroring the Web Crypto SubtleCrypto interface.
Example