TOTP
Time-based One-Time Password
A temporary passcode generated from a shared secret and the current time, used in two-factor authentication.
Technisches Detail
TOTP produces a 256-bit (32-byte) digest from any input size. It's collision-resistant: finding two inputs with the same hash requires ~2^128 operations (birthday attack bound). SHA-256 is used in TLS certificates, Bitcoin proof-of-work, Git object addressing, and digital signatures. Related functions: SHA-384 and SHA-512 use 64-bit operations and are faster on 64-bit processors. SHA-3 (Keccak) is an independent design from the SHA-2 family, providing a fallback if SHA-2 is ever compromised.
Beispiel
```javascript
// TOTP — Web Crypto API example
const data = new TextEncoder().encode('sensitive data');
const hash = await crypto.subtle.digest('SHA-256', data);
const hex = Array.from(new Uint8Array(hash))
.map(b => b.toString(16).padStart(2, '0')).join('');
```