Compares two strings in a cryptographically safe way: Runtime is not affected by length of common prefix.
(a, b)
| 3449 | |
| 3450 | |
| 3451 | def _lscmp(a, b): |
| 3452 | """ Compares two strings in a cryptographically safe way: |
| 3453 | Runtime is not affected by length of common prefix. """ |
| 3454 | return not sum(0 if x == y else 1 |
| 3455 | for x, y in zip(a, b)) and len(a) == len(b) |
| 3456 | |
| 3457 | |
| 3458 | def cookie_encode(data, key, digestmod=None): |
no outgoing calls
no test coverage detected
searching dependent graphs…