我如何解压这段代码?

[ad_1]

该代码本身不压缩..

但是当与 Zlib 结合使用时,它会压缩..

请参阅 compress_loop()

它从十六进制输入流的末尾开始并对每个数字进行平方。
if 将最后一个十六进制数字放入输出,并将余数进位到下一个输入数字。

我正在寻找可以解压其输出的人……

[edit]

来自OP,作为解决方案发布:

引用:

源代码是用 FreeBasic 编写的

[/edit]

我尝试过的:

Declare Function      compress_loop( chrs as string ) as string
Declare Function decompress_loop( chrs as string ) as string

screen 19
'=====================================================================
'=====================================================================
'start program
'=====================================================================
'=====================================================================
dim as double time1 , time2 , time3 , time4
do
   
    randomize
   
    dim as string s = ""
    For n As Long = 1 To 8
        s+=chr(Int(Rnd*256))
    Next
   
    time1=timer
    'begin compress
        dim as string comp = s
            'do
            '    dim as longint chk = len(comp) - 1
            '    comp = compress_loop(comp)
            '    if len(comp) >= chk then exit do
            'loop
            for a as longint = 1 to 1 step 1
                comp = compress_loop(comp)
            next
    'end compress
    time2 = timer
   
    time3=timer
    'begin decompress
        dim as string final_out = comp
        for a as longint = 1 to 1 step 1
            final_out = decompress_loop(final_out)
        next
    'end decompress
    time4 = timer
   
   'sleep
   
    'cls
    'draw string( 0,10) , left(s,100)
    'draw string( 0,30) , left(final_out,100)
    print string(99,"=")
    print "inp = " ; (s)
    print string(99,"=")
    print "out = " ; (final_out)
    print
    print "compress time   = "; time2-time1
    print "decompress time = "; time4-time3
    print
   
    if s = final_out then print "Decompressed OK" else print "Decompression failed."
    print string(99,"=")
   
    sleep
   
loop until inkey = chr(27)

sleep
end
'===============================================================================
'===============================================================================
'compress
'===============================================================================
'===============================================================================
Function compress_loop( chrs as string ) as string
   
    print "c inp = " ; len(chrs)
   
    dim as string bits = ""
    dim as string zeros = string( 2 , "0" )
    dim as string n1
    dim as ubyte ptr usp = cptr( ubyte ptr , strptr( chrs ) )
    for a as longint = 1 to len( chrs ) step 1
        n1 = zeros + hex( *usp ) : usp+= 1
        n1 = right( n1 , 2 )
        bits+= n1
    next
   
    print "c bin = " ; len(bits) , bits
    
    dim as string outs1 = string( len( bits ) , "0" )
    dim as string s1 , s2 , s3
    dim as longint v1 , v2 , carry
    zeros = "000"
    for a as longint = len( bits ) to 1 step - 1
            
            's1 = str( ( val( "&H" + mid( bits , a , 1 ) ) ^ 2 ) + carry ) : carry = 0
            's2 = right( "000" + hex( val( s1 ) ) , 3 )
            
            v1 = bits[ a - 1 ]
            
            if v1 = 48 then v2 = 000 + carry : goto done
            if v1 = 49 then v2 = 001 + carry : goto done
            if v1 = 50 then v2 = 004 + carry : goto done
            if v1 = 51 then v2 = 009 + carry : goto done
            if v1 = 52 then v2 = 016 + carry : goto done
            if v1 = 53 then v2 = 025 + carry : goto done
            if v1 = 54 then v2 = 036 + carry : goto done
            if v1 = 55 then v2 = 049 + carry : goto done
            if v1 = 56 then v2 = 064 + carry : goto done
            if v1 = 57 then v2 = 081 + carry : goto done
            if v1 = 65 then v2 = 100 + carry : goto done
            if v1 = 66 then v2 = 121 + carry : goto done
            if v1 = 67 then v2 = 144 + carry : goto done
            if v1 = 68 then v2 = 169 + carry : goto done
            if v1 = 69 then v2 = 196 + carry : goto done
            if v1 = 70 then v2 = 225 + carry : goto done
            
            done:
            
            carry = 0
            
            s2 = zeros + hex( v2 )
            s2 = right( s2 , 3 )
            
            carry = val( "&H" + left( s2 , 2 ) ) 
            s3 = right( s2 , 1 )

            outs1[ a - 1 ] = s3[ 0 ]
            
            'print v1 ,  s2 , s3 ', outs1
            'sleep
            'if inkey = " " then end
            
    next
    
    if carry > 0 then outs1 = hex( carry ) + outs1
    
    print "c out = " ; len( outs1 ) , outs1
    
    dim as ubyte count = 0
    if len( outs1 ) mod 2 = 1 then outs1+= "0" : count = 1
        
    dim as string final = ""
    for a as longint = 1 to len( outs1 ) step 2
        final+= chr( val( "&H" + mid( outs1 , a , 2 ) ) )
    next
    
    final = chr( count ) + final
    
    print "c fin = " ; len(final)
   
    return final
   
end function
'===============================================================================
'============================================================================
Function decompress_loop( chrs as string ) as string
   
    print "dc inp = " ; len(chrs)
    
    dim as ubyte count = asc( left( chrs , 1 ) )
    chrs = mid( chrs , 2 )
    
    dim as string bits = ""
    dim as string zeros = string( 2 , "0" )
    dim as string n1
    dim as ubyte ptr usp = cptr( ubyte ptr , strptr( chrs ) )
    for a as longint = 1 to len( chrs ) step 1
        n1 = zeros + hex( *usp ) : usp+= 1
        n1 = right( n1 , 2 )
        bits+= n1
    next
    
    bits = left( bits , len( bits ) - count )
    
    print "d bin = " ; len(bits) , bits
   
    return chrs 
   
end function

解决方案2

对您的“附加信息解决方案”进行排序后,我查看了问题,然后……

不,事情并不是这样的。 我们不会为您对大量代码进行逆向工程 – 这要么是您的工作并且您会因此获得报酬,要么它是您作业的一部分,这对您、您的同学或您的未来不公平雇主。

我们不会为您做您的工作。
如果你想让别人写你的代码,你就必须付费——我建议你去 Freelancer.com 并在那里询问。

但请注意:一分钱一分货。 付花生钱,得到猴子。

“发展”的理念顾名思义:“系统地运用科学技术知识来满足特定的目标或要求”。 商业词典网[^]

这与“快速谷歌一下,如果找不到正确的代码就放弃”不是一回事。
因此,要么花钱请人来做,要么学习如何自己编写。 我们不是来为你做这件事的。

解决方案3

也许你可以在这里尝试 Zlib 示例: fbc/zlib.bas at master · freebasic/fbc · GitHub[^]

解决方案4

引用:

我如何解压这段代码?

很难猜测你想要什么,因为提供的代码没有压缩并且与压缩无关。
我们必须猜测“压缩”这个词在您的头脑中意味着什么。
在您清楚地解释您的需求之前,我们无能为力。

解决方案5

def 压缩(原始文本):
总和=1
前一个字符=“”
压缩文本=“”
对于(original_text)中的字符:
如果 previous_char == 字符:
总和=总和+1
压缩文本+=字符+str(总和)
打印()
别的:
总和=1
压缩文本+=字符+str(总和)
previous_character=字符
返回(压缩文本)

[ad_2]

コメント

标题和URL已复制