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刪除。