0

I have a project where i used gzip in .cs file to zip the data. Here is my code.

public byte[] CustomerList()
{
    SqlDataAdapter da = new SqlDataAdapter("select CustomerID from CustomerMaster", con);

    DataSet ds = new DataSet();
    da.Fill(ds);
    return CompressData(ds);
}
public byte[] CompressData(DataSet ds)
{
    using (MemoryStream memory = new MemoryStream())
    {
        using (GZipStream gzip = new GZipStream(memory, CompressionMode.Compress))
        {
            var formatter = new BinaryFormatter();
            formatter.Serialize(gzip, ds);
            gzip.Close();
        }

        return memory.ToArray();
    }
}

I called this zip function form my js file and getting the data as a byte format.

<script type="text/javascript" language="javascript">
$(document).ready(function () {

                $.ajax({
                    type: "POST",
                    url: "Service1.svc/CustomerList",
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    processdata: true,
                    success: function (data) {
                        alert(data.CustomerListResult);
                    },
                    error: function () {
                        alert("Error");
                    }
                });
            });

Now i want to decrypt this [byte-data] to get the original string. Here the issue started. How should i get the original data that means how i would decrypt or unzip the [byte data] to get the original string.

Saikat
  • 390
  • 2
  • 8
  • 25

1 Answers1

1

There is simillar your question. JavaScript implementation of Gzip and JavaScript: Decompress / inflate /unzip /ungzip strings

Community
  • 1
  • 1
Oh Jong Am
  • 136
  • 8