aboutsummaryrefslogtreecommitdiff
path: root/slides/2019-side-channels/img/strcmp.py
diff options
context:
space:
mode:
authorRasmus Dahlberg <rasmus@rgdd.se>2024-10-15 15:35:20 +0200
committerRasmus Dahlberg <rasmus@rgdd.se>2024-10-15 15:35:45 +0200
commit76bae02bcd7d6b3ec9eea428e5e95da184a8dbfb (patch)
tree410ab71c78c99d35aecd46733958a5699cdf5204 /slides/2019-side-channels/img/strcmp.py
parent883a67439aff566962adafeb0385c6ae972073a3 (diff)
Rescue some slides from old private mono repos
Diffstat (limited to 'slides/2019-side-channels/img/strcmp.py')
-rwxr-xr-xslides/2019-side-channels/img/strcmp.py18
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)))