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.

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

1 Comment

will you please provide the link.. Thank in advance.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.