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:
Private Function B10To256(ByVal initVal As Double, ByVal Character_Return As Long, Optional ByVal DoFlip As Boolean) As String Dim lng As Long Dim bA(3) As Byte If initVal > 2147483647 Then lng = initVal - 4294967296# Else lng = initVal CopyMemory bA(0), lng, 4 If DoFlip Then B10To256 = StrReverse(Right$(StrReverse(StrConv(bA, vbUnicode)), Character_Return)) Else B10To256 = Right$(StrReverse(StrConv(bA, vbUnicode)), Character_Return) End If End Function Private Function Adler32(ByVal strIn As String) As String Dim bString() As Byte Dim A As Long, B As Long, X as Long bString = StrConv(strIn, vbFromUnicode) A = 1 For X = 0 To UBound(bString) A = (A + bString(X)) Mod 65521 B = (B + A) Mod 65521 Next X B = B * 256 + A Adler32 = B10To256(B, 4) End Function




Reply With Quote