base64 - gzip base64 在 linux 和 windows 上编码和解码字符串

标签 base64 gzip

我有一个编码字符串,它是在 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();
        }
    }
}

关于base64 - gzip base64 在 linux 和 windows 上编码和解码字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42459909/

相关文章:

Java顺序解压GZIP流

c++ - 尝试将 gz 文件提供给 C++ 程序

PHP从base64编码的数据字符串中获取pdf文件

typescript - 为什么我不能在 array ionic 3 中获得完整的 base64 字符串?

encoding - Base64解码给出不同的结果

node.js - 在通过 API Gateway V2 提供服务的 AWS Lambda 函数中进行 Gzip 压缩会在浏览器上抛出 ERR_CONTENT_DECODING_FAILED

google-app-engine - Google App Engine 中的 GZIP 内容使用 django-nonrel

javascript - CryptoKey ArrayBuffer 到 base64 和返回

base64 - 编码/解码base64

c++ - C++ 中的 ZLib 解压缩