aboutsummaryrefslogtreecommitdiff
path: root/ls47.py
diff options
context:
space:
mode:
authorMirek Kratochvil <exa.exa@gmail.com>2026-11-20 09:01:54 +0100
committerMirek Kratochvil <exa.exa@gmail.com>2026-11-20 09:01:54 +0100
commitcd5dc67cd98553fc10c7efeaaa675abe68730d01 (patch)
tree0deb0e051756cb1d7d8a6b70080d7db479f36b43 /ls47.py
parent2977d7c2a6c26dfb7e55ba73b079ace3f163d296 (diff)
downloadls47-cd5dc67cd98553fc10c7efeaaa675abe68730d01.tar.gz
ls47-cd5dc67cd98553fc10c7efeaaa675abe68730d01.tar.bz2
fix password expansion (lol uppercase)
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: