Rot13是一种非常简单的替换加密算法,只能加密26个英语字母。方法是:把每个字母用其后第13个字母代替。
因为有26个字母,取其一半13。
s = "xrlvf23xfqwsxsqf"
ans = ""
for i in s:
if 'a' <= i <= 'z':
ans += chr(((ord(i)-ord('a')) + 13) % 26 + ord('a'))
else:
ans+=i
print(ans)
Rot13是一种非常简单的替换加密算法,只能加密26个英语字母。方法是:把每个字母用其后第13个字母代替。
因为有26个字母,取其一半13。
s = "xrlvf23xfqwsxsqf"
ans = ""
for i in s:
if 'a' <= i <= 'z':
ans += chr(((ord(i)-ord('a')) + 13) % 26 + ord('a'))
else:
ans+=i
print(ans)
本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。