farbe für ausgabe

This commit is contained in:
2025-07-29 23:21:47 +02:00
parent 79ea033bb6
commit afdb6234dd

View File

@@ -1656,9 +1656,10 @@ def vigenere(eingabetext, pw):
else:
decoded_text += ubw[ba].lower()
decoded_text_s += ubw[bas].lower()
ausgabetext = f"_Dekodiert - normal:_ \n{decoded_text} \n \n_Kodiert - normal:_ \n{encoded_text} \n \n"
ausgabetext += f"_Dekodiert - Sonderzeichen verbrauchen Schlüsselbuchstaben:_ \n{decoded_text_s} \n \n"
ausgabetext += f"_Kodiert - Sonderzeichen verbrauchen Schlüsselbuchstaben:_ \n{encoded_text_s}"
ausgabetext = (f":blue[Dekodiert - normal:] \n{decoded_text} \n \n"
f":blue[Kodiert - normal:] \n{encoded_text} \n \n"
f":blue[Dekodiert - Sonderzeichen verbrauchen Schlüsselbuchstaben:] \n{decoded_text_s} \n \n"
f":blue[Kodiert - Sonderzeichen verbrauchen Schlüsselbuchstaben:] \n{encoded_text_s}")
return ausgabetext
def wolseley(eingabetext, pw):
@@ -1672,7 +1673,7 @@ def wolseley(eingabetext, pw):
else:
for b in pw:
if b.upper() not in "ABCDEFGHIJKLMNOPQRSTUVWXYZ":
return "Das Passwort darf nur die Buchstaben A-Z / a-z enthalten!"
return ":red[Das Passwort darf nur die Buchstaben A-Z / a-z enthalten!]"
text = text.upper()
pw = pw.upper()
if "J" in text:
@@ -1734,7 +1735,7 @@ def monoalphasubstitution(eingabetext, pw):
abc = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
for b in pw:
if b.upper() not in abc:
return "Das Schlüsselwort/Schlüsselalphabet darf nur die Buchstaben A-Z / a-z enthalten!"
return ":red[Das Schlüsselwort/Schlüsselalphabet darf nur die Buchstaben A-Z / a-z enthalten!]"
cabc = ""
for b in pw.upper() + abc:
if b not in cabc:
@@ -1761,10 +1762,10 @@ def monoalphasubstitution(eingabetext, pw):
decoded_txt += ucab[b.upper()].lower()
else:
decoded_txt += b
ausgabetext = f"_Dekodiert:_ \n{decoded_txt} \n \n"
ausgabetext += f"_Kodiert:_ \n{encoded_txt} \n \n"
ausgabetext = f":blue[Dekodiert:] \n{decoded_txt} \n \n"
ausgabetext += f":blue[Kodiert:] \n{encoded_txt} \n \n"
if len(pw) < len(abc):
ausgabetext += f"Schlüsselalphabet wurde wie folgt aufgefüllt: {cabc}"
ausgabetext += f":blue[Schlüsselalphabet wurde wie folgt aufgefüllt:] {cabc}"
return ausgabetext
def autokey(eingabetext, pw):
@@ -1784,7 +1785,7 @@ def autokey(eingabetext, pw):
p_wd = ""
for b in pw:
if b.upper() not in bw:
return "Das Schlüsselwort darf nur die Buchstaben A-Z / a-z enthalten!"
return ":red[Das Schlüsselwort darf nur die Buchstaben A-Z / a-z enthalten!]"
else:
p_we += b.upper() # Sonderzeichen aus PW entfernen und
p_wd += b.upper()
@@ -1825,8 +1826,8 @@ def autokey(eingabetext, pw):
decoded_text += ubw[ba]
else:
decoded_text += ubw[ba].lower()
ausgabetext = f"_Dekodiert:_ \n{decoded_text} \n \n"
ausgabetext += f"_Kodiert:_ \n{encoded_text}"
ausgabetext = (f":blue[Dekodiert:] \n{decoded_text} \n \n"
f":blue[Kodiert:] \n{encoded_text}")
return ausgabetext
def polybios_encode(eingabetext, pw):
@@ -1903,21 +1904,21 @@ def polybios_encode(eingabetext, pw):
ctext6 = ""
for b in text6:
ctext6 += wb6[b]
ausgabetext = "|Polybios 5x5 (j=i)| |\n"
ausgabetext = "|:green[Polybios 5x5 (j=i)]| |\n"
ausgabetext += "|-|-|\n"
ausgabetext += f"|Klartext|{text5ij}|\n"
ausgabetext += f"|Schlüsselwort|{passw5ij}|\n"
ausgabetext += f"|kodiert|{ctext5ij}\n \n"
ausgabetext += "|Polybios 5x5 (v=u)| |\n"
ausgabetext += f"|:blue[Klartext]|{text5ij}|\n"
ausgabetext += f"|:blue[Schlüsselwort]|{passw5ij}|\n"
ausgabetext += f"|:blue[kodiert]|{ctext5ij}\n \n"
ausgabetext += "|:green[Polybios 5x5 (v=u)]| |\n"
ausgabetext += "|-|-|\n"
ausgabetext += f"|Klartext|{text5uv}|\n"
ausgabetext += f"|Schlüsselwort|{passw5uv}|\n"
ausgabetext += f"|kodiert|{ctext5uv}|\n \n"
ausgabetext += "|Polybios 6x6| |\n"
ausgabetext += f"|:blue[Klartext]|{text5uv}|\n"
ausgabetext += f"|:blue[Schlüsselwort]|{passw5uv}|\n"
ausgabetext += f"|:blue[kodiert]|{ctext5uv}|\n \n"
ausgabetext += "|:green[Polybios 6x6]| |\n"
ausgabetext += "|-|-|\n"
ausgabetext += f"|Klartext|{text6}|\n"
ausgabetext += f"|Schlüsselwort|{passw6}|\n"
ausgabetext += f"|kodiert|{ctext6}|\n"
ausgabetext += f"|:blue[Klartext]|{text6}|\n"
ausgabetext += f"|:blue[Schlüsselwort]|{passw6}|\n"
ausgabetext += f"|:blue[kodiert]|{ctext6}|\n"
return ausgabetext
def polybios_decode(eingabetext, pw):
@@ -1986,18 +1987,18 @@ def polybios_decode(eingabetext, pw):
ctext5ij += " "
ctext5uv += " "
ctext6 += " "
ausgabetext = "|Polybios 5x5 (j=i)| |\n"
ausgabetext = "|:green[Polybios 5x5 (j=i)]| |\n"
ausgabetext += "|-|-|\n"
ausgabetext += f"|Schlüsselwort|{passw5ij}|\n"
ausgabetext += f"|dekodiert|{ctext5ij}|\n \n"
ausgabetext += "|Polybios 5x5 (v=u)| |\n"
ausgabetext += f"|:blue[Schlüsselwort]|{passw5ij}|\n"
ausgabetext += f"|:blue[dekodiert]|{ctext5ij}|\n \n"
ausgabetext += "|:green[Polybios 5x5 (v=u)]| |\n"
ausgabetext += "|-|-|\n"
ausgabetext += f"|Schlüsselwort|{passw5uv}|\n"
ausgabetext += f"|dekodiert|{ctext5uv}|\n \n"
ausgabetext += "|Polybios 6x6| |\n"
ausgabetext += f"|:blue[Schlüsselwort]|{passw5uv}|\n"
ausgabetext += f"|:blue[dekodiert]|{ctext5uv}|\n \n"
ausgabetext += "|:green[Polybios 6x6]| |\n"
ausgabetext += "|-|-|\n"
ausgabetext += f"|Schlüsselwort|{passw6}|\n"
ausgabetext += f"|dekodiert|{ctext6}|\n"
ausgabetext += f"|:blue[Schlüsselwort]|{passw6}|\n"
ausgabetext += f"|:blue[dekodiert]|{ctext6}|\n"
return ausgabetext
def klopfcode_encode(eingabetext):
@@ -2019,8 +2020,8 @@ def klopfcode_encode(eingabetext):
ctext = ""
for b in text5:
ctext += wb5[b]
ausgabetext = f"Klartext: {text5} \n"
ausgabetext += f"kodiert: {ctext}"
ausgabetext = f":blue[Klartext:] {text5} \n"
ausgabetext += f":blue[kodiert:] {ctext}"
return ausgabetext
def klopfcode_decode(eingabetext):
@@ -2041,7 +2042,7 @@ def klopfcode_decode(eingabetext):
if cc in wb:
ctext += wb[cc]
ctext += " "
return f"Klopfcode dekodiert: \n{ctext}"
return f":blue[Klopfcode dekodiert]: \n{ctext}"
def maptiles_kachelkoordinaten(eingabetext):
text = eingabetext.rstrip()
@@ -2050,7 +2051,7 @@ def maptiles_kachelkoordinaten(eingabetext):
else:
text = text.split()
if "." in text[0] and len(text) == 2:
ausgabetext = "DEC -> Maptiles \n|Zoom|X|Y|\n|-|-|-|\n"
ausgabetext = ":violet[DEC -> Maptiles] \n|:blue[Zoom]|:blue[X]|:blue[Y]|\n|-|-|-|\n"
for zoom in range(1, 26):
try:
la = float(text[0])
@@ -2062,7 +2063,7 @@ def maptiles_kachelkoordinaten(eingabetext):
pass
return ausgabetext, None
elif len(text) == 2:
ausgabetext = "Maptiles->DEG,DEC \n|Zoom|DEG|DEC|\n|-|-|-|\n"
ausgabetext = ":violet[Maptiles->DEG,DEC] \n|:blue[Zoom]|:blue[DEG]|:blue[DEC]|\n|-|-|-|\n"
lat_list, lon_list = [], []
for zoom in range(2, 26):
try:
@@ -2075,7 +2076,7 @@ def maptiles_kachelkoordinaten(eingabetext):
pass
return ausgabetext, pd.DataFrame({'lat': lat_list, 'lon': lon_list})
else:
return "Zahlen konnten nicht ermittelt werden!", None
return ":red[Zahlen konnten nicht ermittelt werden!]", None
def quadtree_koordinaten(eingabetext):
text = eingabetext.rstrip()
@@ -2105,13 +2106,13 @@ def quadtree_koordinaten(eingabetext):
fehler += 1
la, lo = helper.maptiles_to_dec(tile_x, tile_y, zoom)
if fehler == 0:
ausgabetext = f"Maptiles: X:{tile_x} Y:{tile_y} Zoom:{zoom} \n"
ausgabetext += f"DEC: {round(la, 5)} {round(lo, 5)} \n"
ausgabetext += f"DEG: {helper.dec_to_deg(la, lo)}"
ausgabetext = f":blue[Maptiles: X:] {tile_x} :blue[Y:] {tile_y} :blue[Zoom:] {zoom} \n"
ausgabetext += f":blue[DEC:] {round(la, 5)} {round(lo, 5)} \n"
ausgabetext += f":blue[DEG:] {helper.dec_to_deg(la, lo)}"
return ausgabetext, pd.DataFrame({'lat': [la], 'lon': [lo]})
else:
return ("Es konnte keine gültige Quadtree-Koordinate erkannt werden. (eine Zahl die nur die Ziffern "
"0,1,2,3 enthält)"), None
return (":red[Es konnte keine gültige Quadtree-Koordinate erkannt werden. (eine Zahl die nur die Ziffern "
"0,1,2,3 enthält)]"), None
def chronogramm(eingabetext):
text = eingabetext.rstrip()
@@ -2146,7 +2147,7 @@ def chronogramm(eingabetext):
sum_einfach = i + (v * 5) + (x * 10) + (ll * 50) + (c * 100) + (d * 500) + (m * 1000)
sum_erweitert = sum_einfach + (u * 5) + j
sum_extrem = sum_erweitert + (y * 2) + (w * 10)
ausgabetext = "|Buchstabe|Wert|Anzahl|Summe\n|-|-|-|-|\n"
ausgabetext = "|:blue[Buchstabe]|:blue[Wert]|:blue[Anzahl]|:blue[Summe]|\n|-|-|-|-|\n"
ausgabetext += f"|I|1|{i}|{i}|\n"
ausgabetext += f"|V|5|{v}|{v*5}|\n"
ausgabetext += f"|X|10|{x}|{x*10}|\n"
@@ -2158,9 +2159,9 @@ def chronogramm(eingabetext):
ausgabetext += f"|U(=V)|5|{u}|{u*5}|\n"
ausgabetext += f"|Y(=I+I)|2|{y}|{y*2}|\n"
ausgabetext += f"|W(=V+V)|10|{w}|{w*10}\n \n"
ausgabetext += f"Summe einfach(I,V,X,L,C,D,M): {sum_einfach} \n"
ausgabetext += f"Summe erweitert(inkl. I,U): {sum_erweitert} \n"
ausgabetext += f"Summe extrem(inkl.J,U,Y,W): {sum_extrem}"
ausgabetext += f":blue[Summe einfach(I,V,X,L,C,D,M):] {sum_einfach} \n"
ausgabetext += f":blue[Summe erweitert(inkl. I,U):] {sum_erweitert} \n"
ausgabetext += f":blue[Summe extrem(inkl.J,U,Y,W):] {sum_extrem}"
return ausgabetext
def zahlen_roemisch_arabisch_umwandeln(eingabetext):
@@ -2191,7 +2192,7 @@ def zahlen_roemisch_arabisch_umwandeln(eingabetext):
try:
zahl = int(rz)
if zahl > 500000:
return "arabische Zahlen größer als 500000 mag ich nicht in römische Zahlen!"
return ":red[arabische Zahlen größer als 500000 mag ich nicht in römische Zahlen!]"
rom = ""
for az, romz in azr:
count = zahl // az
@@ -2199,7 +2200,7 @@ def zahlen_roemisch_arabisch_umwandeln(eingabetext):
rom += romz * count
return f"{rz} = {rom}"
except ValueError:
return "Es konnte keine römische oder arabische Zahl erkannt werden!"
return ":red[Es konnte keine römische oder arabische Zahl erkannt werden!]"
return ""
def url_decode(eingabetext):
@@ -2208,7 +2209,7 @@ def url_decode(eingabetext):
return hilfetexte.url_decode
else:
atxt = urllib_parse_unquote(eingabetext)
return f"dekodierte URL: `{atxt}`"
return f":blue[dekodierte URL:] `{atxt}`"
def reversewig(eingabetext):
seperator = ("|,", "_", "/", ";", ",")
@@ -2251,10 +2252,11 @@ def base64_ascii(eingabetext):
else:
try:
ascii_string = binascii.a2b_base64(eingabetext).decode()
return f"Base64 -> ASCII: \n{ascii_string} \n"
return f":blue[Base64 -> ASCII:] \n{ascii_string} \n"
except ValueError:
base64_string = binascii.b2a_base64(eingabetext.encode())
return f"Umwandlung Base64 -> ASCII war nicht möglich. \nASCII -> Base64: \n{base64_string.decode()}"
return (f":red[Umwandlung Base64 -> ASCII war nicht möglich.] \n"
f":blue[ASCII -> Base64:] \n{base64_string.decode()}")
def jaegerzaun_encrypt(eingabetext, pw):
if pw is None:
@@ -2264,15 +2266,15 @@ def jaegerzaun_encrypt(eingabetext, pw):
if eingabetext == "":
return hilfetexte.jaegerzaun_encrypt
elif pw == "" or not pw.isdigit():
return "Bitte eine Zahl im Schlüsselfeld eingeben!!"
return ":red[Bitte eine Zahl im Schlüsselfeld eingeben!!]"
else:
try:
if int(pw) < 2:
raise ValueError("Zahl zu klein")
return (f"_inkl. Leerzeichen_ \n{helper.rail_encrypt(eingabetext, int(pw))} \n \n"
f"_ohne Leerzeichen_ \n{helper.rail_encrypt(eingabetext.replace(" ", ""), int(pw))}")
return (f":blue[inkl. Leerzeichen] \n{helper.rail_encrypt(eingabetext, int(pw))} \n \n"
f":blue[ohne Leerzeichen] \n{helper.rail_encrypt(eingabetext.replace(" ", ""), int(pw))}")
except ValueError:
return "Schlüsselzahl fehlerhaft oder kleiner als 2."
return ":red[Schlüsselzahl fehlerhaft oder kleiner als 2.]"
def jaegerzaun_decrypt(eingabetext, pw):
if pw is None:
@@ -2282,16 +2284,15 @@ def jaegerzaun_decrypt(eingabetext, pw):
if eingabetext == "":
return hilfetexte.jaegerzaun_decrypt
elif pw == "":
ausgabtext = ""
ausgabtext += "_inkl. Leerzeichen_ \n"
ausgabtext = ":blue[inkl. Leerzeichen] \n"
for i in range(12, 1, -1):
ausgabtext += f'{i:02} - {helper.rail_decrypt(eingabetext, i)} \n'
ausgabtext += " \n_ohne Leerzeichen_ \n"
ausgabtext += f':blue[{i:02}:] {helper.rail_decrypt(eingabetext, i)} \n'
ausgabtext += " \n:blue[ohne Leerzeichen] \n"
for i in range(12, 1, -1):
ausgabtext += f'{i:02} - {helper.rail_decrypt(eingabetext.replace(" ", ""), i)} \n'
ausgabtext += f':blue[{i:02}:] {helper.rail_decrypt(eingabetext.replace(" ", ""), i)} \n'
return ausgabtext
elif not pw.isdigit():
return "Bitte eine Zahl im Schlüsselfeld eingeben!!"
return ":red[Bitte eine Zahl im Schlüsselfeld eingeben!!]"
else:
try:
if int(pw) < 2:
@@ -2317,7 +2318,7 @@ def adfgx_kodieren(eingabetext, pw):
text = text.upper().replace("J", "I")
pw = pw.upper().replace("J", "I").split(",")
if len(pw) != 2:
return "Es es werden genau zwei durch Komma getrennte Passwörter benötigt!"
return ":red[Es es werden genau zwei durch Komma getrennte Passwörter benötigt!]"
pw[0] = pw[0].strip()
pw[1] = pw[1].strip()
pw1az = ""
@@ -2381,10 +2382,10 @@ def adfgx_kodieren(eingabetext, pw):
else:
ausgabe_za += i[j + 1]
z += 1
ausgabetext = f"_Passwort 1:_ {pw[0]} \n"
ausgabetext += f"_Passwort 2:_ {pw2} \n \n"
ausgabetext += f"_kodiert mit Variante A-Z:_ \n{ausgabe_az} \n \n"
ausgabetext += f"_kodiert mit Variante Z-A:_ \n{ausgabe_za}"
ausgabetext = f":blue[Passwort 1:] {pw[0]} \n"
ausgabetext += f":blue[Passwort 2:] {pw2} \n \n"
ausgabetext += f":blue[kodiert mit Variante A-Z:] \n{ausgabe_az} \n \n"
ausgabetext += f":blue[kodiert mit Variante Z-A:] \n{ausgabe_za}"
return ausgabetext
def adfgx_dekodieren(eingabetext, pw):
@@ -2405,7 +2406,7 @@ def adfgx_dekodieren(eingabetext, pw):
pw = pw.replace("J", "I")
pw = pw.split(",")
if len(pw) != 2:
return "Es es werden genau zwei durch Komma getrennte Passwörter benötigt!"
return ":red[Es es werden genau zwei durch Komma getrennte Passwörter benötigt!]"
pw[0] = pw[0].strip()
pw[1] = pw[1].strip()
pw1az = ""
@@ -2452,10 +2453,10 @@ def adfgx_dekodieren(eingabetext, pw):
bi = ctext[i:i + 2]
if bi in w_bza:
klartext_za += w_bza[bi]
ausgabetext = f"_Passwort 1:_ {pw[0]} \n"
ausgabetext += f"_Passwort 2:_ {pw2} \n \n"
ausgabetext += f"_dekodiert mit Variante A-Z:_ \n{klartext_az} \n \n"
ausgabetext += f"_dekodiert mit Variante Z-A:_ \n{klartext_za}"
ausgabetext = f":blue[Passwort 1:] {pw[0]} \n"
ausgabetext += f":blue[Passwort 2:] {pw2} \n \n"
ausgabetext += f":blue[dekodiert mit Variante A-Z:] \n{klartext_az} \n \n"
ausgabetext += f":blue[dekodiert mit Variante Z-A:] \n{klartext_za}"
return ausgabetext
def adfgvx_kodieren(eingabetext, pw):
@@ -2474,7 +2475,7 @@ def adfgvx_kodieren(eingabetext, pw):
text = text.upper()
pw = pw.upper().split(",")
if len(pw) != 2:
return "Es es werden genau zwei durch Komma getrennte Passwörter benötigt!"
return ":red[Es es werden genau zwei durch Komma getrennte Passwörter benötigt!]"
pw[0] = pw[0].strip()
pw[1] = pw[1].strip()
pw1az09 = ""
@@ -2537,10 +2538,10 @@ def adfgvx_kodieren(eingabetext, pw):
else:
ausgabe_90za += i[j + 1]
z += 1
ausgabetext = f"_Passwort 1:_ {pw[0]} \n"
ausgabetext += f"_Passwort 2:_ {pw2} \n \n"
ausgabetext += f"_kodiert mit Variante A-Z,0-9:_ \n{ausgabe_az09} \n \n"
ausgabetext += f"_kodiert mit Variante 9-0,Z-A:_ \n{ausgabe_90za}"
ausgabetext = f":blue[Passwort 1:] {pw[0]} \n"
ausgabetext += f":blue[Passwort 2:] {pw2} \n \n"
ausgabetext += f":blue[kodiert mit Variante A-Z,0-9:] \n{ausgabe_az09} \n \n"
ausgabetext += f":blue[kodiert mit Variante 9-0,Z-A:] \n{ausgabe_90za}"
return ausgabetext
def adfgvx_dekodieren(eingabetext, pw):
@@ -2560,7 +2561,7 @@ def adfgvx_dekodieren(eingabetext, pw):
pw = pw.upper()
pw = pw.split(",")
if len(pw) != 2:
return "Es es werden genau zwei durch Komma getrennte Passwörter benötigt!"
return ":red[Es es werden genau zwei durch Komma getrennte Passwörter benötigt!]"
pw[0] = pw[0].strip()
pw[1] = pw[1].strip()
pw1az09 = ""
@@ -2607,10 +2608,10 @@ def adfgvx_dekodieren(eingabetext, pw):
bi = ctext[i:i + 2]
if bi in wb90za:
klartext_90za += wb90za[bi]
ausgabetext = f"_Passwort 1:_ {pw[0]} \n"
ausgabetext += f"_Passwort 2:_ {pw2} \n \n"
ausgabetext += f"_dekodiert mit Variante A-Z,0-9:_ \n{klartext_az09} \n \n"
ausgabetext += f"_dekodiert mit Variante 9-0,Z-A:_ \n{klartext_90za}"
ausgabetext = f":blue[Passwort 1:] {pw[0]} \n"
ausgabetext += f":blue[Passwort 2:] {pw2} \n \n"
ausgabetext += f":blue[dekodiert mit Variante A-Z,0-9:] \n{klartext_az09} \n \n"
ausgabetext += f":blue[dekodiert mit Variante 9-0,Z-A:] \n{klartext_90za}"
return ausgabetext
# noch nicht implementierte Funktionen: