43 lines
1.1 KiB
Python
43 lines
1.1 KiB
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf8 -*-
|
|
|
|
# Klartext: Beispielklartext
|
|
# Schlüssel: Apfelstrudel
|
|
# Chiffrat: 31 14 35 21 12 35 14 15 41 15 11 23 22 14 53 22
|
|
|
|
text = "Beispielklartextjuiv"
|
|
PW = "Apfelstrudelijuv"
|
|
Z = "0123456789"
|
|
QZ5 = [11, 12, 13, 14, 15, 21, 22, 23, 24, 25, 31, 32, 33, 34, 35, 41, 42, 43, 44, 45, 51, 52, 53, 54, 55]
|
|
alpha5ij = "ABCDEFGHIKLMNOPQRSTUVWXYZ" # j wird durch i ersetzt
|
|
alpha5uv = "ABCDEFGHIJKLMNOPQRSTUWXYZ" # v wird durch u ersetzt
|
|
QZ6 = [11, 12, 13, 14, 15, 16, 21, 22, 23, 24, 25, 26, 31, 32, 33, 34, 35, 36, 41, 42, 43, 44, 45, 46, 51, 52, 53, 54,
|
|
55, 56, 61, 62, 63, 64, 65, 66]
|
|
alpha6 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
|
|
|
|
text = text.upper()
|
|
textij = text.replace("J", "I")
|
|
textuv = text.replace("V", "U")
|
|
PW = PW.upper()
|
|
PWi = PW.replace("J", "I")
|
|
PWu = PW.replace("V", "U")
|
|
|
|
PW5ij = ""
|
|
for b in PWi + alpha5ij:
|
|
if b in alpha5ij and b not in PW5ij:
|
|
PW5ij += b
|
|
PW5uv = ""
|
|
for b in PWu + alpha5uv:
|
|
if b in alpha5uv and b not in PW5uv:
|
|
PW5uv += b
|
|
PW6 = ""
|
|
for b in PW + alpha6:
|
|
if b in alpha6 and b not in PW6:
|
|
PW6 += b
|
|
|
|
print(PW5ij)
|
|
print(PW5uv)
|
|
print(PW6)
|
|
print(PW)
|
|
print(textij)
|