Sign in to follow this  
Followers 0
autoItrules209

(String-) Compression an crypting, zlib_udf.au3 issue

2 posts in this topic

Im currently "playing" with Compression and encryption in Autoit. Btw I want to use RAM, not write to file, run a tool, re-read the file!

first I found the build-in _StringEncrypt - a encrypted string ist 4 times as large as the decrypted one, is there any other algorithm for crypting that doent expand the string (or at least not as much)?

Handeling Compression I started using zLib_UDF from

http://www.autoitscript.com/forum/index.php?showtopic=87284

.

It was working pretty ine in the beginning, but then I discovered an Issue. Sometimes Compression return "-5" instead of the compressed string.

Heres my Code:

#include "zlib_udf.au3"
$i = 0
While 1
    $str = ""
    $strlength = 16399
    For $j = 1 To $strlength
        $str &= Chr(Random(0, 255, 1))
    Next

    $bin = StringToBinary($str)
    $binlength = BinaryLen($bin)
    _Zlib_Startup()
    $compressed = _Zlib_CompressBinary($bin)

    $uncompressed = _Zlib_UncompressBinary($compressed, $binlength)
    _Zlib_Shutdown()

    If StringCompare(BinaryToString($uncompressed), $str)<>0 Then
        FileWrite("bug" & $i & ".txt", $str)
        MsgBox(0, $i & "    " & $strlength & "    " & StringCompare(BinaryToString($uncompressed), $str), ($compressed));BinaryToString)

    EndIf
    $i += 1
WEnd

So I create a Random string and compress & decompress it, making a MsgBox when decompressed string is NOT what would be expected

Very Strange about this bug:

It NEVER occurs using Chr 4 and up, even though it never occurs using a length of 16390 and less.

using 16500, every random string is affected by this error, BUT ONLY if there are letters generated which are 4 and less ($str &= Chr(Random(4, 255, 1)) works fine, even using a length of 100.000

reagrds

Share this post


Link to post
Share on other sites



No Ideas?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0