Einzelnen Beitrag anzeigen
Alt 14.04.09, 19:15   #43 (permalink)
pytohn
 
Benutzerbild von pytohn
 
Registriert seit: 28.03.09
pytohn Leistung: Facit NTK
Likes: 0
Standard

python3

kann nur cäsar und kann nur eingegebenen string ver-/entschlüsseln. habe vor, dateien vielleicht in den nächsten tagen noch ein zu bauen.


Code:
def encode(char, str):
    clear = "abcdefghijklmnopqrstuvwxyz"
    cryptic = clear[clear.index(char):] + clear[:clear.index(char)]

    crystr = ""

    str = str.lower()
    
    for i in str:
        if i not in clear:
            new = i
        else:
            new = cryptic[clear.index(i)]

        crystr = crystr + new

    return crystr

def decode(char, str):
    clear = "abcdefghijklmnopqrstuvwxyz"
    cryptic = clear[clear.index(char):] + clear[:clear.index(char)]

    enstr = ""

    str = str.lower()

    for i in str:
        if i not in cryptic:
            new = i
        else:
            new = clear[cryptic.index(i)]

        enstr = enstr + new

    return enstr
pytohn ist offline   Mit Zitat antworten
 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61