Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def poczatek(tekst):
- tekst=tekst.replace(" ","")
- tekst=tekst.lower()
- return tekst
- def szyfrcezara(tekst,przesuniecie):
- nowy=""
- x=len(tekst)
- for i in range (0,x):
- y=ord(tekst[i])+przesuniecie
- if y>122:
- y=96+(y-122)
- nowy=nowy+chr(y)
- return nowy
- def odszyfrcezara(tekst,n):
- nowy=""
- x=len(tekst)
- for i in range(0,x):
- y = ord(tekst[i]) - n
- if y < 97:
- y = 123 - (97-y)
- nowy = nowy + chr(y)
- return nowy
- def podstawieniowy(tekst,alfabet):
- x=len(tekst)
- nowy=""
- for i in range(0,x):
- y=ord(tekst[i])
- nowy=nowy+alfabet[y-97]
- return nowy
- def odpodsatwieniowy(tekst,alfabet):
- stary=""
- x=len(tekst)
- for i in range(0,x):
- stary=stary+chr(97+alfabet.find(tekst[i]))
- return stary
- n=int(input("Podaj przesunięcie:"))
- tekst1=input("podaj tekst:")
- tekst1=poczatek(tekst1)
- print(szyfrcezara(tekst1,n))
- tekst2=szyfrcezara(tekst1,n)
- print(odszyfrcezara(tekst2,n))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement