使用ASCII和base 128混淆字符串

hhh*_*hhh 2 python obfuscation encoding ascii

假设一个字符串是一个数字系统,其中每个东西,它可以是char,DEL或任何ASCII的东西,根据这个ASCII 具有相应的数字.如何在Python中将属性的任意字符串转换为数字?

一个例子

#car = 35*128**3+99*128**2+97*128**1+114*128**0=75034866
Run Code Online (Sandbox Code Playgroud)

Mar*_*ers 7

试试这个:

total = 0
for c in "#car":
    total <<= 7
    total += ord(c)
print total
Run Code Online (Sandbox Code Playgroud)

结果:

75034866

要取回原始字符串:

result = []
while total:
    result.append(chr(total % 128))
    total >>= 7
print ''.join(reversed(result))
Run Code Online (Sandbox Code Playgroud)

结果:

#car