Commit 3cc6fbb7 by sikang

bug fix

parent b8f65ff6
......@@ -5,6 +5,18 @@ import random
import base64
class StringGarble:
used_names = []
# 随机串(全小写加下划线,避免和activity混淆重复)
def __gen_rand_str(self):
result = ""
while len(result) == 0 or result in self.__used_names:
result = ''.join(random.sample(
"abcdefghijklmnopqrstuvwxyz", random.randint(5, 10)))
self.__used_names.append(result)
return result
#字符串混淆
def __string_garble(self,path):
with open(path, "r") as f:
......@@ -34,7 +46,9 @@ class StringGarble:
strings = ""
for i in range(0,random.randint(100,500)):
strings += "<string>%s</string>\n"% ''.join(random.choices(string.ascii_uppercase + string.ascii_lowercase, k=random.randint(5, 100)))
key = self.__gen_rand_str()
value = ''.join(random.choices(string.ascii_uppercase + string.ascii_lowercase, k=random.randint(5, 100)))
strings += "<string name=\"%s\">%s</string>\n"% (key,value)
with open(path, "w") as f_w:
fileContent = fileContent.replace("</resources>","%s\n</resources>"% strings)
f_w.write(fileContent)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment