我有一个编码字符串,它是在Linux机器上使用以下命令进行编码的:
cat <file-name> | gzip | base64 -w0
我可以使用下面的方法解码并串联字符串:
echo '<encoded-string> | base64 -di | zcat
在Windows机器上是否有解码相同字符串的方法。
方法:
echo VERY_LARGE_STRING | gzip | base64 -w0
... 受到 Linux 设置的限制:
getconf ARG_MAX
使用了下面的代码,救了我的一天。非常感谢 Karthik1234。
cat <file-name> | gzip | base64 -w0
以下是我们在C#中解压缩Linux中压缩的消息的方法 注意:您可能需要删除最后一个字节。
static byte[] Decompress(byte[] gzip)
{
// Create a GZIP stream with decompression mode.
// ... Then create a buffer and write into while reading from the GZIP stream.
using (GZipStream stream = new GZipStream(new MemoryStream(gzip),
CompressionMode.Decompress))
{
const int size = 4096;
byte[] buffer = new byte[size];
using (MemoryStream memory = new MemoryStream())
{
int count = 0;
do
{
count = stream.Read(buffer, 0, size);
if (count > 0)
{
memory.Write(buffer, 0, count);
}
}
while (count > 0);
return memory.ToArray();
}
}
}