Jump to content

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

Recommended Posts

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



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))

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

    $uncompressed = _Zlib_UncompressBinary($compressed, $binlength)

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

    $i += 1

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


Link to comment
Share on other sites

  • 2 weeks later...

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...