diff options
Diffstat (limited to 'slides/2019-side-channels/img/strcmp.py')
-rwxr-xr-x | slides/2019-side-channels/img/strcmp.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/slides/2019-side-channels/img/strcmp.py b/slides/2019-side-channels/img/strcmp.py new file mode 100755 index 0000000..89688fc --- /dev/null +++ b/slides/2019-side-channels/img/strcmp.py @@ -0,0 +1,18 @@ +#!/usr/bin/python + +def is_equal(s1, s2): + ''' + Returns true if the strings s1 and s2 encode the same information. + ''' + if len(s1) != len(s2): + return False + + for (x,y) in zip(s1,s2): + if x != y: + return False + + return True + +target, strs = "abc", [ "ab", "abc", "abcd", "bbc", "abe" ] +for s in strs: + print("{} == {} ? {}".format(target,s,is_equal(target,s))) |