Giter VIP home page Giter VIP logo

Comments (4)

0x4092 avatar 0x4092 commented on May 27, 2024 9

我尝试用你这个程序去编码大约60.7MiB的二进制文件(base64编码过的),8G内存就爆了

from core-values-encoder.

mengyyy avatar mengyyy commented on May 27, 2024 3

解码

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.

mengyyy avatar mengyyy commented on May 27, 2024 1

这样应该会好一点
编码

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.

kouhe3 avatar kouhe3 commented on May 27, 2024

运行结果令人生草

from core-values-encoder.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.