使用键重新排列字符串 [英] using a key to rearrange string
本文介绍了使用键重新排列字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用Python我想随机重新排列基于给定键的字符串的部分。我还想使用相同的键恢复原始字符串:
Using Python I want to randomly rearrange sections of a string based on a given key. I also want to restore the original string with the same key:
def rearrange(key, data):
pass
def restore(key, rearranged_data):
pass
效率并不重要。任何想法?
Efficiency is not important. Any ideas?
编辑:
- 可以假设密钥是可散列的,但可能是多种类型
- 段的定义ignacio
- can assume key is hashable, but may be multiple types
- definition of section for ignacio
推荐答案
你可以重塑轮子,但为什么不尝试<一个href =http://www.pycrypto.org/ =nofollow noreferrer>加密库如果可能的话。
you can reinvent the wheel, but why not try an encryption library first, if possible.
这篇关于使用键重新排列字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文