Comments (4)
我尝试用你这个程序去编码大约60.7MiB的二进制文件(base64编码过的),8G内存就爆了
from core-values-encoder.
解码
VALUE_PAIR = ('富强', '**', '文明', '和谐', '自由', '平等', "公正", '法治', "爱国", '敬业', '诚信', '友善')
def values2duo(value):
it = iter(value)
for v in it:
spicemen = v + next(it)
if spicemen in VALUE_PAIR:
yield VALUE_PAIR.index(spicemen)
def duo2hex(value):
it = iter(values2duo(value))
for v in it:
if v < 10:
yield v
elif v == 10:
yield 10 + next(it)
else:
yield 6 + next(it)
def valueDecode(value):
it = iter(duo2hex(value))
for v in it:
ca = (v<<4) + next(it)
if ca < 256 :
yield bytes([ca])
print(b''.join(valueDecode('诚信自由爱国爱国文明爱国诚信平等诚信自由平等诚信****爱国自由')).decode('utf-8'))
from core-values-encoder.
这样应该会好一点
编码
def str2utf8(Str):
for i in Str:
for j in i.encode('utf-8').hex().upper():
yield j
def hex2duo(Str):
for h in str2utf8(Str):
numH = int(h, 16)
if numH < 10:
yield(numH)
elif random.random() < 0.5:
yield(10)
yield(numH - 10)
else:
yield(11)
yield(numH - 6)
def duo2values(Str):
for i in hex2duo(Str):
yield VALUES[2 * i] + VALUES[2 * i + 1]
print("".join(duo2values("Hello:!~World测试")))
from core-values-encoder.
运行结果令人生草
from core-values-encoder.
Related Issues (18)
- -
- 请问能再缩短一下长度吗? HOT 2
- 是直接把文件扔到网站根目录吗? HOT 3
- 点了没反应是什么鬼 HOT 1
- 你是不是偷偷补了课
- 闷声作大死
- 再别康桥 HOT 1
- 搞了个tg bot,比较简陋,可以玩一下 HOT 2
- 求制作基于base64的编码器 HOT 4
- new features HOT 3
- 你真他娘是个人才! HOT 34
- Support for emoji HOT 4
- 我觉得为了缩短长度,可以加入标点符号 HOT 3
- 好复杂啊,看看我的 HOT 7
- 建议删去“自由”和“**” HOT 2
- 宣传一下Chrome插件 HOT 7
- 为什么hex2duo要用到随机数? HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from core-values-encoder.