crypto.verify()
Compares byte sequences.
Signature
crypto.verify(first, second)
Parameters
Two text or packed values.
Returns
Boolean.
Behavior
Compares equal-length bytes in constant time. Different lengths return false immediately.
Errors
Invalid byte input.
Example
use crypto
a = crypto.hash('sha256', 'Atom')
assert(crypto.verify(a, copy(a)))
Compare two text values
Use verify when comparing a received authentication value with an expected one.
use crypto
print(crypto.verify('match', 'match'))
true
The text values have the same bytes.
Compare packed bytes
A digest or tag is often already stored in binary form.
use binary
use crypto
first = binary.unhex('0102')
second = binary.unhex('0103')
print(crypto.verify(first, second))
false
The two buffers differ in their last byte.