release 1.10

This commit is contained in:
2024-03-17 16:04:06 +01:00
parent be9e204576
commit 3c40cfb341
14 changed files with 254 additions and 33 deletions

View File

@@ -16,17 +16,17 @@ def array_ausgabe(arri: list):
def encrypt(plain_text: str, rails: int):
arr = [["_" for x in range(len(plain_text))] for y in range(rails)]
arr = [["_" for _ in range(len(plain_text))] for _ in range(rails)]
r = 0
z = 0
plus = True
for b in plain_text:
arr[r][z] = b
z += 1
if r+1 == rails and plus:
if r + 1 == rails and plus:
plus = False
r -= 1
elif r-1 < 0 and not plus:
elif r - 1 < 0 and not plus:
plus = True
r += 1
elif plus:
@@ -40,15 +40,44 @@ def encrypt(plain_text: str, rails: int):
out += arr[i][j]
print(out)
array_ausgabe(arr)
print()
def decrypt(cipher: str, rails: int):
arr = [["" for x in range(len(cipher))] for y in range(rails)]
for r in range(rails):
#arr[r][z] = b
pass
arr = [["_" for _ in range(len(cipher))] for _ in range(rails)]
# cipher ins array reinbasteln
x, y = 0, 0
first_x = True
for b in cipher:
if x >= len(cipher) and y < rails:
y += 1
x = y
first_x = True
arr[y][x] = b
if y == 0 or (first_x and y != rails-1):
x = x + (rails - y - 1) * 2
first_x = False
elif y == rails-1 or first_x is False:
x = x + (y * 2)
first_x = True
array_ausgabe(arr)
# dekodierten Text aus array holen
out = ""
x, y = 0, 0
down = True
for i in range(len(cipher)):
out += arr[y][x]
x += 1
if down and y+1 == rails:
down = False
y -= 1
elif down:
y += 1
elif down is False and y == 0:
down = True
y += 1
elif down is False:
y -= 1
print(out)
encrypt(t1r2, 2)