奇怪的文本编码器/解码器。提供可逆、可读和无损编码。
dizzer的Python项目详细描述
头晕
双向人类可读奇怪文本编码器/解码器。
对于原文中的每一个原始单词,它都将它的第一个和最后一个字符留在 位置,但会将单词中间的所有字符洗牌(置换)。如果可能的话, 产生的“编码”单词与原始单词不同。在
或“保留比4个字符短的单词”, “看见”,“月亮”不能被置乱-因为交换它的字符没有效果。在
主要功能:
- 简单,直截了当
- 100%可翻译-后退和第四
- 编解码器是无损的,不需要任何额外的数据翻译
- 把所有的数字和slug也加起来
- 保持其他非word文本部分不变
置乱顺序是伪随机的,每个字的置乱顺序不同。在
用法
importdizzeroriginal_text="""Text can contain unlimited number of whitespaces, newlines etc.Numbers like 12345, 1234567, 987654321 or 123456789 are also scrambled."""encoded=dizzer.encode(original_text)print(encoded)# Txet can cnitaon umnitelid nmeubr of wtsehaecips, newniels etc.# Numbres lkie 14325, 1346257, 967843251 or 143267859 are aslo scrmeabld.# reverse operation:decoded=dizzer.decode(encoded)print(decoded)# Text can contain unlimited number of whitespaces, newlines etc.# Numbers like 12345, 1234567, 987654321 or 123456789 are also scrambled.
安装
^{pr2}$它没有依赖关系,可以在python3.7、3.8、3.9和pypy3中使用。在
互操作性检查
算法工作的概率不为零 不同于复杂的环境(例如,当您的python解释器 使用奇怪的伪随机生成器库)。在
在导入dizzer
包时,有一个self check语句。
它检查这个算法在您的环境中是否有效。
如果检测到故障,则有一个片段会引发导入错误。
换句话说,如果你能进口头晕-你可以确定,你的
编码文本可以在othr机器上解码。在
自检语句
importdizzerPROPER_TEXT="""This sentence approves that dizzer can be used on your machine.If this assertion is not raised - it means you can read and write messagesthat are fully translatable on other machines."""EXPECTED_ENCODING="""Tihs senectne aepvorps taht dzzier can be uesd on yuor mhcaine.If tihs aosirtsen is not risaed - it mneas you can raed and wtrie msesgeastaht are fluly tbnslalatrae on oethr mhacneis."""local_encoding=dizzer.encode(PROPER_TEXT)back=dizzer.decode(local_encoding)assertlocal_encoding==EXPECTED_ENCODING,"Failed to encode."assertback==PROPER_TEXT,"Failed to decode."
- 项目
标签: