Results 1 to 25 of 25

Thread: [RESOLVED] Decompress GZip

Threaded View

  1. #17
    Fanatic Member FireXtol's Avatar
    Join Date
    Apr 2010
    Posts
    874

    Re: Decompress GZip

    There's 2 extra characters before the zlib stream(compression info and flags), and 4 after(adler32).

    http://www.ietf.org/rfc/rfc1950.txt

    Or basically: strData = Chr$(&H78) & Chr$(&H9C) & strData & Adler32(strData)

    Where strData was the compressed stream in the gzip stream.

    I don't see customizing the flags having any real effect, so using those two characters should probably work for most any stream.

    The Adler32 was simple:

    vb Code:
    1. Private Function B10To256(ByVal initVal As Double, ByVal Character_Return As Long, Optional ByVal DoFlip As Boolean) As String
    2.       Dim lng As Long
    3.       Dim bA(3) As Byte
    4.  
    5.     If initVal > 2147483647 Then lng = initVal - 4294967296# Else lng = initVal
    6.     CopyMemory bA(0), lng, 4
    7.     If DoFlip Then
    8.       B10To256 = StrReverse(Right$(StrReverse(StrConv(bA, vbUnicode)), Character_Return))
    9.     Else
    10.       B10To256 = Right$(StrReverse(StrConv(bA, vbUnicode)), Character_Return)
    11.     End If
    12.  
    13. End Function
    14.  
    15. Private Function Adler32(ByVal strIn As String) As String
    16. Dim bString() As Byte
    17. Dim A As Long, B As Long, X as Long
    18. bString = StrConv(strIn, vbFromUnicode)
    19. A = 1
    20. For X = 0 To UBound(bString)
    21.     A = (A + bString(X)) Mod 65521
    22.     B = (B + A) Mod 65521
    23. Next X
    24. B = B * 256 + A
    25. Adler32 = B10To256(B, 4)
    26. End Function
    Last edited by FireXtol; May 2nd, 2010 at 03:49 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width