From cd5dc67cd98553fc10c7efeaaa675abe68730d01 Mon Sep 17 00:00:00 2001 From: Mirek Kratochvil Date: Fri, 20 Nov 2026 09:01:54 +0100 Subject: fix password expansion (lol uppercase) --- ls47.py | 16 +++++++++------- 1 file 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: -- cgit v1.2.3