Side-channel attacks
Timing Attack Visualization
See how early-exit comparisons can leak information through timing. Compare a vulnerable string comparison with a constant-time approach using safe local demo values.
Ethical demo only
This page simulates timing costs locally. Do not use timing tests against systems or accounts you do not own or have permission to test.
Timing comparison
Vulnerable comparison cost grows with the matched prefix. Constant-time comparison keeps the cost closer to the full input length.
Vulnerable avg cost
48.67
Leaks prefix length
Constant-time avg cost
78.00
Avoids early exit
Leaked prefix
cry
What timing may reveal
Risk
medium
Based on matched-prefix length
Explanation
Timing attacks work when comparison code exits early and response time reveals how many characters were correct. Constant-time comparison keeps work roughly independent of the matching prefix.
Attempt samples
Costs are deterministic demo units, not real wall-clock timings. They make the leak visible without attacking any external system.
| Sample | Guess | Matched prefix | Vulnerable cost | Constant-time cost | Match |
|---|---|---|---|---|---|
| 1 | crysta | 3 | 50 | 79 | no |
| 2 | crysta | 3 | 47 | 78 | no |
| 3 | crysta | 3 | 48 | 77 | no |
| 4 | crysta | 3 | 48 | 77 | no |
| 5 | crysta | 3 | 47 | 78 | no |
| 6 | crysta | 3 | 51 | 78 | no |
| 7 | crysta | 3 | 47 | 78 | no |
| 8 | crysta | 3 | 49 | 78 | no |
| 9 | crysta | 3 | 50 | 79 | no |
| 10 | crysta | 3 | 50 | 79 | no |
| 11 | crysta | 3 | 49 | 78 | no |
| 12 | crysta | 3 | 48 | 77 | no |