
Public Domain
Python
2021年01月10日
#Caesar Cipher in Cryptography
def encrypt(text,s):
alpha='abcdefghijklmnopqrstuvwxyz'
cipher=(alpha*2)[s:s+26]
output=''
for i in text.lower():
output +=cipher[alpha.find(i)] if i in alpha else i
return output.upper()
def main():
Text=input('Text :')
Shift=int(input('Shift :'))
print(f'Output : {encrypt(Text,Shift)}')
if __name__ == "__main__":
main()
Pythonでシーザー暗号をやってみた ordやchrを使ってやるのが本筋だと思うけど、自分は暗号リストを作って付き合わせる 人のやり方をプログラムにやらせている
No one still commented. Please first comment.
Output