First i am encrypt string and then after decrypt the string.
- protected void Page_Load(object sender, EventArgs e)
- {
-
- string Hex = Convert_StringvalueToHexvalue("Nikhil",System.Text.Encoding.Unicode);
-
-
- string str = Convert_HexvalueToStringvalue(Hex, System.Text.Encoding.Unicode);
-
- }
-
- public static string Convert_StringvalueToHexvalue(string stringvalue, System.Text.Encoding encoding)
- {
- Byte[] stringBytes = encoding.GetBytes(stringvalue);
- StringBuilder sbBytes = new StringBuilder(stringBytes.Length * 2);
- foreach (byte b in stringBytes)
- {
- sbBytes.AppendFormat("{0:X2}", b);
- }
- return sbBytes.ToString();
- }
- public static string Convert_HexvalueToStringvalue(string hexvalue, System.Text.Encoding encoding)
- {
- int CharsLength = hexvalue.Length;
- byte[] bytesarray = new byte[CharsLength / 2];
- for (int i = 0; i < CharsLength; i += 2)
- {
- bytesarray[i / 2] = Convert.ToByte(hexvalue.Substring(i, 2), 16);
- }
- return encoding.GetString(bytesarray);
- }