Skip to content
Snippets Groups Projects
Commit d916148e authored by Bensong Liu's avatar Bensong Liu
Browse files

make the noob code better

parent e783aa0a
No related branches found
No related tags found
No related merge requests found
# Chinese OBFS
This is a fork of BullshitGenerator.
This tool could encode (hide) any data into nonsense chinese text, to avoid the extreme censorship of chinese forum.
This tool should be used to decode data from nonsense chinese text.
## Format proposal
The first section encodes the topic.
The second section should use the bootstrap data.json and the topic above, to encode an url to actual data.json.
The third section is the actual data section.
----
# 狗屁不通文章生成器 # 狗屁不通文章生成器
# BullshitGenerator # BullshitGenerator
......
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import os, re
import random
def loadJson(fileName):
import json
strList = fileName.split(".")
if strList[len(strList)-1].lower() == "json":
with open(fileName,mode='r',encoding="utf-8") as file:
return json.loads(file.read())
data = loadJson("data.json")
motto_data = data["famous"] # a 代表prefix_data,b代表postfix_data
prefix_data = data["before"] # 在motto_data前面弄点nonsense_data
postfix_data = data['after'] # 在motto_data后面弄点nonsense_data
nonsense_data = data['bosh'] # 代表文章主要nonsense_data来源
xx = "学生会退会"
repeat_factor = 2
def randomized_yield(iterable):
global repeat_factor
pool = list(iterable) * repeat_factor
while True:
random.shuffle(pool)
for ele in pool:
yield ele
nonsense_generator = randomized_yield(nonsense_data)
motto_generator = randomized_yield(motto_data)
def new_motto():
global motto_generator
xx = next(motto_generator)
xx = xx.replace("a", random.choice(prefix_data) )
xx = xx.replace("b", random.choice(postfix_data) )
return xx
def new_paragraph():
xx = ". "
xx += "\r\n"
xx += " "
return xx
if __name__ == "__main__":
xx = input("请输入文章主题:")
for x in xx:
tmp = str()
while ( len(tmp) < 6000 ) :
randsrc = random.randint(0,100)
if randsrc < 5:
tmp += new_paragraph()
elif randsrc < 20 :
tmp += new_motto()
else:
tmp += next(nonsense_generator)
tmp = tmp.replace("x",xx)
print(tmp)
# -*- coding: utf-8 -*-
# @Author: Admin
# @Date: 2019-11-01 16:52:34
# @Last Modified by: Admin
# @Last Modified time: 2019-11-01 18:18:14
def 读JSON文件(fileName=""):
import json
if fileName!='':
strList = fileName.split(".")
if strList[len(strList)-1].lower() == "json":
with open(fileName,mode='r',encoding="utf-8") as file:
return json.loads(file.read())
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import os, re
import random,readJSON
data = readJSON.读JSON文件("data.json")
名人名言 = data["famous"] # a 代表前面垫话,b代表后面垫话
前面垫话 = data["before"] # 在名人名言前面弄点废话
后面垫话 = data['after'] # 在名人名言后面弄点废话
废话 = data['bosh'] # 代表文章主要废话来源
xx = "学生会退会"
重复度 = 2
def 洗牌遍历(列表):
global 重复度
= list(列表) * 重复度
while True:
random.shuffle()
for 元素 in :
yield 元素
下一句废话 = 洗牌遍历(废话)
下一句名人名言 = 洗牌遍历(名人名言)
def 来点名人名言():
global 下一句名人名言
xx = next(下一句名人名言)
xx = xx.replace( "a",random.choice(前面垫话) )
xx = xx.replace( "b",random.choice(后面垫话) )
return xx
def 另起一段():
xx = ". "
xx += "\r\n"
xx += " "
return xx
if __name__ == "__main__":
xx = input("请输入文章主题:")
for x in xx:
tmp = str()
while ( len(tmp) < 6000 ) :
分支 = random.randint(0,100)
if 分支 < 5:
tmp += 另起一段()
elif 分支 < 20 :
tmp += 来点名人名言()
else:
tmp += next(下一句废话)
tmp = tmp.replace("x",xx)
print(tmp)
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment