🔐 Computes the SHA-256 hash of a string, returning a hex string.
Info
Always returns a `Promise`. Uses the standard Web Crypto API (`crypto.subtle`).
Syntax
TypeScript
import { sha256 } from '@opentf/std'; sha256(input: string): Promise<string>;
Parameters
| Name | Type | Description |
|---|---|---|
| input | string | The string to hash. |
Returns
A hex-encoded SHA-256 hash string (64 characters).
Examples
TypeScript
await sha256('hello') //=> '2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824'