python实现换位加密算法的示例
时间:2021-12-03 09:27:18|栏目:Python代码|点击: 次
如下所示:
def translationCipher(msg,key):
result = [""]*key
for i in range(key):#把每一列元素按照顺序相加组成新的字符序列
pointer = i
while i<len(msg):
result[pointer]+=msg[i]
i+=key
return ''.join(result)
def main():
print translationCipher("hello,world",4)#以4个字母为一行进行换位加密
if __name__=="__main__":
main()
上一篇:Python 把两层列表展开平铺成一层(5种实现方式)
栏 目:Python代码
本文标题:python实现换位加密算法的示例
本文地址:http://www.codeinn.net/misctech/185654.html






