灵活的Rot13功能

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了灵活的Rot13功能相关的知识,希望对你有一定的参考价值。

This function takes 2 arguments, first is the string to be encoded (or decoded) the second is optional and can be used to change the rotation amount to something other than 13.
  1. def rot(s, n=13):
  2. r = ""
  3. for c in s:
  4. cc = c
  5. if cc.isalpha():
  6. cc = cc.lower()
  7. o = ord(cc)
  8. ro = (o+n) % 122
  9. if ro == 0: ro = 122
  10. if ro < 97: ro += 96
  11. cc = chr(ro)
  12. r = ''.join((r,cc))
  13. return r

以上是关于灵活的Rot13功能的主要内容,如果未能解决你的问题,请参考以下文章

rot13加密

rot13加密

php 解密eval(gzinflate(str_rot13(base64_decode

ROT13 加密与解密

我无法弄清楚我的代码有啥问题

javascript ROT13