MCPcopy Index your code
hub / github.com/fluentpython/example-code-2e / _lscmp

Function _lscmp

21-async/mojifinder/bottle.py:2597–2600  ·  view source on GitHub ↗

Compares two strings in a cryptographically safe way: Runtime is not affected by length of common prefix.

(a, b)

Source from the content-addressed store, hash-verified

2595 return r
2596
2597def _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
2603def cookie_encode(data, key):

Callers 1

cookie_decodeFunction · 0.85

Calls 1

sumFunction · 0.85

Tested by

no test coverage detected