请求识别一款从Android App反编译得到的自定义加密算法
自定义字符串加解密算法分析
反编译一款Android App(疑似混淆器遗留产物)时发现了这套字符串处理算法,它会在处理字符串时被调用,但无法归类为已知标准加密算法。以下是用Python重写的实现代码:
def decodeStr(input: str, intCode: int, charSecCode: str, mode: int) -> str: outString = "" for charIndex in range(len(input)): inputCurrChar = ord(input[charIndex]) & 65535 if mode == 3: code = inputCurrChar - (intCode + charIndex) - ord(charSecCode) elif mode == 0: code = (inputCurrChar - (intCode + charIndex)) + ord(charSecCode) else: code = inputCurrChar - (intCode * 3) + ord(charSecCode) if code < 0: moduloCode = -(-code % 127) else: moduloCode = code % 127 if moduloCode < 0: moduloCode += 127 outString += chr(moduloCode) return outString
调用示例
decodeStr("\nx\u0006\r\u0010\n\u0004", 233, '+', 3)
该调用的输出为 samsung。
内容的提问来源于stack exchange,提问作者Christian Fiorenzo
相关产品推荐
相关产品推荐

