Record gzip function

Source: Internet
Author: User

Just make a log and with


public static function Compress (Param1:bytearray): ByteArray
{
var _loc_2:bytearray;
var _loc_3:crc32;
var _loc_4:uint;
var _loc_5:uint;
_loc_2 = new ByteArray ();
_loc_2.endian = Endian.little_endian;
_loc_2.writebyte (31);
_loc_2.writebyte (139);
_loc_2.writebyte (8);
_loc_2.writebyte (0);
_loc_2.writeunsignedint (0);
_loc_2.writebyte (0);
_loc_2.writebyte (255);
_loc_3 = new CRC32 ();
_loc_3.update (param1);
_loc_4 = _loc_3.getvalue ();
_loc_5 = param1.length% Math.pow (2, 32);
Param1.compress ();
_loc_2.writebytes (param1, 0, param1.length);
_loc_2.writeunsignedint (_loc_4);
_loc_2.writeunsignedint (_loc_5);
return _loc_2;
}//End Function

public static function Decompress (Param1:bytearray): ByteArray
{
var _loc_2:bytearray;
var _loc_3:uint;
var _loc_4:uint;
var _loc_5:uint;
var _loc_6:int;
var _loc_7:uint;
var _loc_8:uint;
var _loc_9:uint;
var _loc_10:int;
var _loc_11:bytearray;
var _loc_12:bytearray;
var _loc_13:bytearray;
_loc_2 = new ByteArray ();
_loc_2.endian = Endian.little_endian;
param1.position = 0;
Param1.readbytes (_loc_2, 0, param1.length);
_loc_3 = _loc_2.readunsignedbyte ();
_loc_4 = _loc_2.readunsignedbyte ();
_loc_5 = _loc_2.readunsignedbyte ();
if (_loc_3 = | | _loc_4! = 139 | | _loc_5! = 8)
{
throw new Illegaloperationerror ("");
}//End If
_loc_6 = _loc_2.readbyte ();
_loc_7 = _loc_2.readunsignedint ();
_loc_8 = _loc_2.readunsignedbyte ();
_loc_9 = _loc_2.readunsignedbyte ();
if ((_loc_6 >> 5 & 1) = = 1)
{
_loc_2.readutf ();
}//End If
if ((_loc_6 >> 4 & 1) = = 1)
{
_loc_12 = new ByteArray ();
while (_loc_2.readunsignedbyte ()! = 0)
{
Label
_loc_2.position--;
_loc_12.writebyte (_loc_2.readbyte ());
}//End While
}//End If
if ((_loc_6 >> 3 & 1) = = 1)
{
_loc_13 = new ByteArray ();
while (_loc_2.readunsignedbyte ()! = 0)
{
Label
_loc_2.position--;
_loc_13.writebyte (_loc_2.readbyte ());
}//End While
}//End If
if ((_loc_6 >> 6 & 1) = = 1)
{
_loc_2.readunsignedshort ();
}//End If
_loc_10 = _loc_2.length-_loc_2.position-8;
_loc_11 = new ByteArray ();
_loc_2.readbytes (_loc_11, 0, _loc_10);
_loc_11.uncompress ();
return _loc_11;
}//End Function

Record gzip function

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.