Einzelfunktionenexperimentierverzeichnis in git integriert

This commit is contained in:
2024-03-17 11:13:48 +01:00
parent 99bd1032c2
commit be9e204576
20 changed files with 1025 additions and 1 deletions

View File

@@ -0,0 +1,59 @@
#!/usr/bin/env python3
# -*- coding: utf8 -*-
test = "Hallo"
t1r2 = "rank the code"
t2r2 = "rn h oeaktecd"
t3r3 = "coding"
t4r3 = "cnoigd"
t5r3 = "rank the code"
t6r3 = "r eaktecdnho"
def array_ausgabe(arri: list):
for line in arri:
print("".join(line))
print()
def encrypt(plain_text: str, rails: int):
arr = [["_" for x in range(len(plain_text))] for y 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:
plus = False
r -= 1
elif r-1 < 0 and not plus:
plus = True
r += 1
elif plus:
r += 1
else:
r -= 1
out = ""
for i in range(rails):
for j in range(len(plain_text)):
if arr[i][j] != "_":
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
encrypt(t1r2, 2)
decrypt(t2r2, 2)
encrypt(t3r3, 3)
decrypt(t4r3, 3)
encrypt(t5r3, 3)
decrypt(t6r3, 3)