0

I'm trying to use a gzip c++ library to decompress some text that i compressed using this website that had a tool to do it, but when i try to decompress it in my project it says that its not compressed and fails to decompress. Am i just misunderstanding these compression formats because the names are the same or is this some other issue that i'm not aware of?

    //'test message' compressed using the website
    std::string test_string = R"(eJwrSS0uUchNLS5OTE8FAB8fBMY=)";

    //returns false
    bool is_compressed = gzip::is_compressed(test_string.data(), test_string.size());

    //crashes
    std::string decompressed = gzip::decompress(test_string.data(), test_string.size());
user438383
  • 5,716
  • 8
  • 28
  • 43
  • 2
    Uh, the site compress with GZIP, then show you the Base64 encoded string of the compressed data. Your code doesn't decode that string into byte array – Martheen Aug 19 '22 at 10:21
  • 1
    See https://stackoverflow.com/questions/180947/base64-decode-snippet-in-c – Martheen Aug 19 '22 at 10:23
  • +1 to @Martheen it is because byte array will create non-ASCII characters as well. For your "test message" string, the gzip byte array is "x°+I-.QхM-.NLO�ф" – Manas Singh Aug 19 '22 at 10:28

1 Answers1

1

Website outputs a Base64 encoded string as ASCII, instead of the byte array. I need to decode the Base64 encoding before trying to decompress.

Mark Adler
  • 101,978
  • 13
  • 118
  • 158