(text: string)
| 178 | * Aufrufstelle sichtbar sein. |
| 179 | */ |
| 180 | export async function sha256Hex(text: string): Promise<string> { |
| 181 | const subtle = globalThis.crypto?.subtle; |
| 182 | if (subtle !== undefined) { |
| 183 | try { |
| 184 | const digest = await subtle.digest('SHA-256', encoder.encode(text)); |
| 185 | return [...new Uint8Array(digest)] |
| 186 | .map((byte) => byte.toString(16).padStart(2, '0')) |
| 187 | .join(''); |
| 188 | } catch { |
| 189 | // Ein unsicherer Kontext meldet sich hier und nicht bei der |
| 190 | // Feature-Erkennung. Der Fallback ist die Antwort darauf. |
| 191 | } |
| 192 | } |
| 193 | return sha256HexSync(text); |
| 194 | } |
no test coverage detected