Kee*_*Wit 8 c# vb.net gzip dotnetzip
如何查看字节数组是否包含gzip流?我的应用程序通过带有Base64编码的http post从其他应用程序获取文件.根据提供文件的应用程序的实现,可以对来自Base64字符串的字节数组进行gzip压缩.如何识别gzipped数组?我找到了一些方法,但我认为当有人上传zip文件或编写"坏"zip文件时会出错
这是我发现和工作的东西,但它可以以某种方式被利用吗?
C#
public static bool IsGZip(byte[] arr)
{
return arr.Length >= 2 && arr[0] == 31 && arr[1] == 139;
}
Run Code Online (Sandbox Code Playgroud)
VB.NET
Public Shared Function IsGZip(arr As Byte()) As Boolean
Return arr.Length >= 2 AndAlso arr(0) = 31 AndAlso arr(1) = 139
End Function
Run Code Online (Sandbox Code Playgroud)
如果IsGzip返回true,我的应用程序将解压缩字节数组.