diff options
| author | Mirek Kratochvil <miroslav.kratochvil@uni.lu> | 2025-08-29 09:43:48 +0200 |
|---|---|---|
| committer | Mirek Kratochvil <miroslav.kratochvil@uni.lu> | 2025-08-29 09:43:48 +0200 |
| commit | 91190809c40f09bc6fae57c7a9065fca67070e37 (patch) | |
| tree | 5d7ea5c636403256c6a5134bfa42b50347c8f009 /ls47.py | |
| parent | f346e51d87acc621ed2967793ce8e1e71f82dd78 (diff) | |
| download | ls47-91190809c40f09bc6fae57c7a9065fca67070e37.tar.gz ls47-91190809c40f09bc6fae57c7a9065fca67070e37.tar.bz2 | |
improve more (key expansion needs some work tho)
Diffstat (limited to 'ls47.py')
| -rwxr-xr-x | ls47.py | 18 |
1 files changed, 12 insertions, 6 deletions
@@ -8,7 +8,7 @@ import random -letters = "_abcdefghijklmnopqrstuvwxyz.0123456789,-+*/:?!'()" +letters = "_abcdefghijklmnopqrstuvwxyz.,:?!'()0123456789+-*/" tiles = list(zip(letters, map(lambda x: (x // 7, x % 7), range(7 * 7)))) padding_size = 10 @@ -85,12 +85,18 @@ def rotate_marker_down(m, col, n): def derive_key(password): - i = 0 k = letters for c in password: - (row, col) = find_ix(c) - k = rotate_down(rotate_right(k, i, col), i, row) - i = (i + 1) % 7 + (crow, ccol) = find_pos(k, c) + (rows1, cols1) = find_ix(c) + k = rotate_right(k, crow, cols1) + (crow, ccol) = add_pos((crow, ccol), (0, cols1)) + k = rotate_down(k, ccol, rows1) + (crow, ccol) = add_pos((crow, ccol), (rows1+1, 1)) + (rows2, cols2) = find_ix(find_at_pos(k, (crow, ccol))) + k = rotate_right(k, crow, cols2) + (crow, ccol) = add_pos((crow,ccol), (0, cols2)) + k = rotate_down(k, ccol, rows2) return k @@ -154,7 +160,7 @@ if __name__ == '__main__': print(letters) # print('tiles positions: ' + str(tiles)) - key = derive_key('s3cret_p4ssw0rd/31337') + key = derive_key('a') print('test key: ' + key) enc = encrypt_pad(key, 'conflagrate_the_rose_bush_at_six!', 'peace-vector-3') |
