Compares two strings in a cryptographically safe way: Runtime is not affected by length of common prefix.
(a, b)
| 2595 | return r |
| 2596 | |
| 2597 | def _lscmp(a, b): |
| 2598 | ''' Compares two strings in a cryptographically safe way: |
| 2599 | Runtime is not affected by length of common prefix. ''' |
| 2600 | return not sum(0 if x==y else 1 for x, y in zip(a, b)) and len(a) == len(b) |
| 2601 | |
| 2602 | |
| 2603 | def cookie_encode(data, key): |