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,68 @@
#!/usr/bin/env python3
# -*- coding: utf8 -*-
text = "Beispielklartext abcdefghijklmnopqrstuvwxyz"
# PW="Apfelstrudel"
PW = "teebaum"
# Chiffrat: IWBQYBWVDVZNOWFO ZIHKWXGCBBDVURTYSNQOMLEFPA
abc = "ABCDEFGHIKLMNOPQRSTUVWXYZ" # j wird als i chiffriert
text = text.upper()
PW = PW.upper()
if "J" in text:
text = text.replace("J", "I")
if "J" in PW:
PW = PW.replace("J", "I")
calpha = ""
for b in PW:
if b not in calpha:
calpha += b
for b in abc:
if b not in calpha:
calpha += b
CABC = {calpha[12]: calpha[12]}
c1 = calpha[:12]
c2 = calpha[13:]
c2 = c2[::-1]
for i in range(12):
CABC[c1[i]] = c2[i]
UCABC = {v: k for k, v in CABC.items()}
CABC.update(UCABC)
print(calpha)
atxt = ""
for b in text:
if b in CABC:
atxt += CABC[b]
else:
atxt += b
print(atxt)
hilfe = """
Die Woseley-Chiffre arbeitet mit einem
Schlüsselwort über welches dann ein Codequadrat
/Codealphabet gebildet wird mit welchem dann
sowohl kodiert als auch dekodiert wird.
Angefangen wird dabei mit dem jeweils ersten
Vorkommen eines Buchstaben im Schlüsselwort
und danach folgen die restlichen Buchstaben
des Alphabets die nicht im Schlüsselwort vorkommen.
Da hier nur 25 Zeichen zur Verfügung stehen wird
das J mit dem I zusammengefasst und als I behandelt
und dargestellt. Sonstige Zeichen die nicht im
Codealphabet vorhanden sind werden unverändert
ausgegeben.
Codequadrat mit Schlüsselwort: Teebaum
1 2 3 4 5
1 T E B A U
2 M C D F G
3 H I K L N
4 O P Q R S
5 V W X Y Z
Bei der Chiffrierung/Dechiffrierung wird
im Text nun der erste Buchstabe mit dem
letzten getauscht, der 2. mit dem vorletzten,
usw. also aus T wird Z und umgekehrt,
E<->Y, B<->X, A<->W usw..
nur ein K bleibt ein K
"""