Encrypt code:
string data="query string";
string encodedData = String.Empty;
try
{
byte[] data_byte = Encoding.UTF8.GetBytes(data);
encodedData = HttpUtility.UrlEncode(Convert.ToBase64String(data_byte));
}
catch (Exception exception)
{
//Log exception
}
return encodedData;
Decrypt code
string data="encoded data";
string decodedData = String.Empty;
try
{
byte[] data_byte = Convert.FromBase64String(HttpUtiltity.UrlDecode(data));
decodedData = Encoding.UTF8.GetString(data_byte);
}
catch (Exception exception)
{
//Log exception
}
return decodedData;
0 comments:
Post a Comment