【分享】兽音译者 Python实现
搜集的兽音译者 python实现代码在此分享,非原创```
#兽音译者,一种将“呜嗷啊~”四个字符,通过特殊算法,将明文进行重新组合的加密算法。一种新的咆哮体加密算法。还可以将四个字符任意换成其它的字符,进行加密。
#另,可下载油猴插件Google selected text translator,https://greasyfork.org/en/scripts/36842-google-select-text-translator
#该插件经设置后,不仅可以划词翻译兽音密文,也可生成兽音密文
class HowlingAnimalsTranslator:
__animalVoice="嗷呜啊~"
def __init__(self,newAnimalVoice=None):
self.setAnimalVoice(newAnimalVoice)
def convert(self,txt=""):
txt=txt.strip()
if(txt.__len__()<1):
return ""
result=self.__animalVoice+self.__animalVoice+self.__animalVoice
offset=0
for t in txt:
c=ord(t)
b=12
while(b>=0):
hex=(c>>b)+offset&15
offset+=1
result+=self.__animalVoice
result+=self.__animalVoice
b-=4
result+=self.__animalVoice
return result
def deConvert(self,txt):
txt=txt.strip()
if(not self.identify(txt)):
return "Incorrect format!"
result=""
i=3
offset=0
while(i<txt.__len__()-1):
c=0
b=i+8
while(i<b):
n1=self.__animalVoice.index(txt)
i+=1
n2=self.__animalVoice.index(txt)
c=c<<4|((n1<<2|n2)+offset)&15
if(offset==0):
offset=0x10000*0x10000-1
else:
offset-=1
i+=1
result+=chr(c)
return result
def identify(self,txt):
if(txt):
txt=txt.strip()
if(txt.__len__()>11):
if(txt==self.__animalVoice and txt==self.__animalVoice and txt==self.__animalVoice and txt[-1]==self.__animalVoice and ((txt.__len__()-4)%8)==0):
for t in txt:
if(not self.__animalVoice.__contains__(t)):
return False
return True
return False
def setAnimalVoice(self,voiceTxt):
if(voiceTxt):
voiceTxt=voiceTxt.strip()
if(voiceTxt.__len__()==4):
self.__animalVoice=voiceTxt
return True
return False
def getAnimalVoice(self):
return self.__animalVoice
```
使用方法:实例化一个HowlingAnimalsTranslator对象,调用convert()与deConvert()方法即可进行兽语的加密与解密
如图:
下载链接:
链接:https://pan.baidu.com/s/17bC0MJXhPA2FmyPGbMrWAA
提取码:52pj
--来自百度网盘超级会员V7的分享
土豪下载链接:
用了你的软件,现在我家狗追着我咬{:1_889:} 万能的python 牛逼的一逼 ?这个我喜欢 kksk 这就回家训练昨天出生的小德牧{:301_993:} 感谢分享,收藏了 用什么打开啊
package animal.language.translation;
public class Main {
private static final String empty = "";
private static final char[] dictionary = new char[]{'嗷', '呜', '啊', '~'};
public static void main(String[] args) {
String a = convert("吾爱破解");
System.out.println(a);
System.out.println(unConvert(a));
}
public static String convert(String s) {
if (s == null || s.length() == 0) {
return empty;
}
s = s.trim();
StringBuilder sb = new StringBuilder();
sb.append(dictionary).append(dictionary).append(dictionary);
int offset = 0;
for (int i = 0; i < s.length(); i++) {
int c = s.codePointAt(i);
for (int b = 12; b >= 0; b -= 4) {
int hex = (c >> b) + (offset++) & 15;
sb.append(dictionary[(hex >> 2)]);
sb.append(dictionary[(hex & 3)]);
}
}
sb.append(dictionary);
return sb.toString();
}
public static String unConvert(String s) {
s = s.trim();
if (s.length() < 4) {
return empty;
}
StringBuilder sb = new StringBuilder();
int offset = 0;
for (int i = 3; i < s.length() - 1; ) {
int c = 0;
for (int b = i + 8; i < b; i++) {
int aa = indexOf(s.charAt(i++));
int bb = indexOf(s.charAt(i));
c = c << 4 | ((aa << 2 | bb) + offset) & 0xf;
offset = (offset == 0 ? -1 : offset - 1);
}
System.out.println(c);
sb.append((char) c);
}
return sb.toString();
}
private static int indexOf(char c) {
for (int i = 0; i < dictionary.length; i++) {
if (c == dictionary) {
return i;
}
}
assert false;
return 0;
}
}
三栖德鲁伊 发表于 2022-1-5 14:54
用什么打开啊
我这里直接用python自带的idle shell运行的,具体运行方法如图
页:
[1]