本文整理汇总了C#中ICSharpCode.SharpZipLib.Zip.Compression.Streams.InflaterInputStream.CopyTo方法的典型用法代码示例。如果您正苦于以下问题:C# InflaterInputStream.CopyTo方法的具体用法?C# InflaterInputStream.CopyTo怎么用?C# InflaterInputStream.CopyTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICSharpCode.SharpZipLib.Zip.Compression.Streams.InflaterInputStream
的用法示例。
在下文中一共展示了InflaterInputStream.CopyTo方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Inflate
internal static byte[] Inflate(byte[] buffer)
{
InflaterInputStream inflaterStream = new InflaterInputStream(new MemoryStream(buffer));
MemoryStream outputStream = new MemoryStream();
inflaterStream.CopyTo(outputStream);
return outputStream.ToArray();
}
示例2: DecompressZlib
public static byte[] DecompressZlib(byte[] input)
{
MemoryStream source = new MemoryStream(input);
byte[] result = null;
using (MemoryStream outStream = new MemoryStream())
{
using (InflaterInputStream inf = new InflaterInputStream(source))
{
inf.CopyTo(outStream);
}
result = outStream.ToArray();
}
return result;
}
示例3: Verify
public static bool Verify(string licenseString)
{
if (string.IsNullOrEmpty(licenseString) || !CanDecode(licenseString))
return false;
byte[] licenseData = Convert.FromBase64String(GetLicenceContent(licenseString));
Console.WriteLine(Encoding.GetEncoding("UTF-32BE").GetString(licenseData.Take(4).ToArray()));
var length = (((licenseData[0] & 0xff) << 24) | ((licenseData[1] & 0xff) << 16) | ((licenseData[2] & 0xff) << 8) | (licenseData[3] & 0xff));
var license = licenseData.Skip(4).Take(length).ToArray();
var sign = licenseData.Skip(length + 4).ToArray();
byte[] unzipedData;
using (MemoryStream inStream = new MemoryStream(license.Skip(5).ToArray()))
using (InflaterInputStream zip = new InflaterInputStream(inStream))
using (MemoryStream outStream = new MemoryStream())
{
zip.CopyTo(outStream);
unzipedData = outStream.ToArray();
}
Console.WriteLine(Encoding.ASCII.GetString(unzipedData));
return VerifyDsaMessage(Convert.FromBase64String(PublicKey), license, ConvertToP1363Signature(sign));
}
示例4: PacketReceiverModernAsync
private void PacketReceiverModernAsync(IAsyncResult ar)
{
if (_baseSock == null || _stream == null || !Connected || Crashed)
return; // -- Terminate cycle
if (_baseSock.Available > 0)
{
int packetId = 0;
byte[] data = new byte[0];
#region No Compression
if (!CompressionEnabled)
{
var packetLength = _stream.ReadVarInt();
if (packetLength == 0)
throw new Exception("Reading Error: Packet Length size is 0");
packetId = _stream.ReadVarInt();
data = _stream.ReadByteArray(packetLength - 1);
}
#endregion
#region Compression
else // (CompressionEnabled)
{
var packetLength = _stream.ReadVarInt();
if (packetLength == 0)
throw new Exception("Reading Error: Packet Length size is 0");
var dataLength = _stream.ReadVarInt();
if (dataLength == 0)
{
if (packetLength >= CompressionThreshold)
throw new Exception("Reading Error: Received uncompressed message of size " + packetLength +
" greater than threshold " + CompressionThreshold);
packetId = _stream.ReadVarInt();
data = _stream.ReadByteArray(packetLength - 2);
}
else // (dataLength > 0)
{
var dataLengthBytes = MinecraftStream.GetVarIntBytes(dataLength).Length;
var tempBuff = _stream.ReadByteArray(packetLength - dataLengthBytes); // -- Compressed
using (var outputStream = new MemoryStream())
using (var inputStream = new InflaterInputStream(new MemoryStream(tempBuff)))
//using (var reader = new MinecraftDataReader(new MemoryStream(tempBuff), NetworkMode))
{
inputStream.CopyTo(outputStream);
tempBuff = outputStream.ToArray(); // -- Decompressed
packetId = tempBuff[0]; // -- Only 255 packets available. ReadVarInt doesn't work.
var packetIdBytes = MinecraftStream.GetVarIntBytes(packetId).Length;
data = new byte[tempBuff.Length - packetIdBytes];
Buffer.BlockCopy(tempBuff, packetIdBytes, data, 0, data.Length);
}
}
}
#endregion
OnDataReceived(packetId, data);
}
// -- If it will throw an error, then the cause is too slow _stream dispose
_stream.EndRead(ar);
_stream.BeginRead(new byte[0], 0, 0, PacketReceiverModernAsync, null);
}