aboutsummaryrefslogtreecommitdiff
path: root/ls47.py
diff options
context:
space:
mode:
Diffstat (limited to 'ls47.py')
-rwxr-xr-xls47.py16
1 files changed, 9 insertions, 7 deletions
diff --git a/ls47.py b/ls47.py
index f44d02b..335bcce 100755
--- a/ls47.py
+++ b/ls47.py
@@ -76,15 +76,15 @@ def rotate_down(key, col, n):
def derive_key(password):
- k = ''.join(reversed(letters))
+ k = "".join(reversed(letters))
i = 0
- for c in password + ' ':
- ix = k.find(c,i)
- if ix<0:
+ for c in password + "_":
+ ix = k.find(c, i)
+ if ix < 0:
continue
- k = k[:i] + k[ix] + k[i:ix] + k[ix+1:]
+ k = k[:i] + k[ix] + k[i:ix] + k[ix + 1 :]
i += 1
- return ''.join(reversed(k))
+ return "".join(reversed(k))
def encrypt(key, plaintext):
@@ -196,7 +196,9 @@ if __name__ == "__main__":
args = ap.parse_args()
if args.password:
- key = derive_key(args.password if args.inx else args.password.replace(' ', '_'))
+ key = derive_key(
+ (args.password if args.inx else args.password.replace(" ", "_")).upper()
+ )
elif args.fullkey:
key = args.fullkey
else: