jägerzaun-encrypt

This commit is contained in:
2023-12-02 18:20:30 +01:00
parent 60ab5ed6b1
commit 6b20bddd0d
4 changed files with 57 additions and 2 deletions

1
.gitignore vendored
View File

@@ -1 +1,2 @@
/data/config.txt
/experimentierbereich/

View File

@@ -2,6 +2,7 @@
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/experimentierbereich" />
<excludeFolder url="file://$MODULE_DIR$/venv" />
</content>
<orderEntry type="inheritedJdk" />

3
.idea/misc.xml generated
View File

@@ -1,4 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Black">
<option name="sdkName" value="Python 3.10 (Mysteryhelfer_pyCharm)" />
</component>
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10 (Mysteryhelfer_pyCharm)" project-jdk-type="Python SDK" />
</project>

View File

@@ -4310,9 +4310,58 @@ wird dann Base64-kodiert ausgegeben.
Ausgabe.insert(1.0, "ASCII -> Base64:\n", "bu")
Ausgabe.insert(1.0, "Umwandlung Base64 -> ASCII war nicht möglich.\n", "re")
# ------------------------------------------------------------------------------------------
def rail_encrypt(plain_text: str, rails: int):
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:
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)):
out += arr[i][j]
return out
def jaegerzaun_encrypt():
trennlinie()
eingabetext = Eingabe.get(1.0, END)
eingabetext = eingabetext.strip().replace("\n", " ")
pw = PW_Eingabe.get()
pw = pw.strip()
if eingabetext == "":
Ausgabe.insert(1.0, """HILFE: [encrypt Jägerzaun]
Jägerzaun (auch Railfence oder ZigZag-Chiffre genannt)
""" + "\n\n")
elif pw == "" or not pw.isdigit():
Ausgabe.insert(1.0, "Bitte eine Zahl im Schlüsselfeld eingeben!!\n", "re")
else:
try:
if int(pw) < 2:
raise ValueError("Zahl zu klein")
Ausgabe.insert(1.0, rail_encrypt(eingabetext.replace(" ", ""), int(pw)) + "\n")
Ausgabe.insert(1.0, "ohne Leerzeichen\n", "bu")
Ausgabe.insert(1.0, rail_encrypt(eingabetext, int(pw)) + "\n")
Ausgabe.insert(1.0, "inkl. Leerzeichen\n", "bu")
except ValueError:
Ausgabe.insert(1.0, "Schlüsselzahl fehlerhaft oder kleiner als 2.\n", "re")
# ------------------------------------------------------------------------------------------
def knoeppe_aendern2():
B44.config(text="Button88", command="", bg=bgcolor_default, cursor="")
B45.config(text="Button89", command="", bg=bgcolor_default, cursor="")
@@ -4359,7 +4408,8 @@ def knoeppe_aendern1():
B53.config(text="Wortsuche-EN", command=wortsuche_en, bg="#33aa00", cursor='question_arrow', font=schrift)
B54.config(text="Reverse-Wherigo", command=reversewig, bg="#FFA94F", cursor='question_arrow', font=schrift)
B55.config(text="Base64<->ASCII", command=base64_ascii, bg="#7777ff", cursor='question_arrow', font=schrift)
B56.config(text="Button78", command="", bg=bgcolor_default, cursor="")
B56.config(text="Jägerzaun kodieren", command=jaegerzaun_encrypt, bg="#3388aa", cursor='question_arrow',
font=schrift)
B57.config(text="Button79", command="", bg=bgcolor_default, cursor="")
B58.config(text="Button80", command="", bg=bgcolor_default, cursor="")
B59.config(text="Button81", command="", bg=bgcolor_default, cursor="")