Data type Byte conversion...
-
I want that value of textbox to be converted into base64 string so that i can sent it to another page as encrypted username from response.redirect....what i used <code>Convert.FromBase64String(textbox1.Text);</code> how to save this converted value and in what data type...and i want it converted into string so that i can send encrypted code to another page and then decrypt it and again save it as string.....please suggest any easy way.....
-
I want that value of textbox to be converted into base64 string so that i can sent it to another page as encrypted username from response.redirect....what i used <code>Convert.FromBase64String(textbox1.Text);</code> how to save this converted value and in what data type...and i want it converted into string so that i can send encrypted code to another page and then decrypt it and again save it as string.....please suggest any easy way.....
Use this Code below
string str = textbox1.Text;
string encstr = Convert.ToBase64String(System.Text.Encoding.Unicode.GetBytes(str));
string decstr = System.Text.Encoding.Unicode.GetString(Convert.FromBase64String(encstr));encstr represents the base64 encrypted string which you can pass between pages, and decstr is the string decryption. :rose:
Abhishek Sur
My Latest Articles **Create CLR objects in SQL Server 2005 C# Uncommon Keywords Read/Write Excel using OleDB
**Don't forget to click "Good Answer" if you like to.
-
Use this Code below
string str = textbox1.Text;
string encstr = Convert.ToBase64String(System.Text.Encoding.Unicode.GetBytes(str));
string decstr = System.Text.Encoding.Unicode.GetString(Convert.FromBase64String(encstr));encstr represents the base64 encrypted string which you can pass between pages, and decstr is the string decryption. :rose:
Abhishek Sur
My Latest Articles **Create CLR objects in SQL Server 2005 C# Uncommon Keywords Read/Write Excel using OleDB
**Don't forget to click "Good Answer" if you like to.
THNX!!!! alot :) i got my problem solved...but please could you explain it....i can't understand the use of ascii encoding then base64 string use....
-
THNX!!!! alot :) i got my problem solved...but please could you explain it....i can't understand the use of ascii encoding then base64 string use....
Well,
Convert.ToBase64String
takes a byte array. You need to convert your string toByte
array. You can do it using afor
loop and create the Byte array yourself.System.Text.Encoding.Unicode.GetBytes
does it for you. :cool: On the contrary, the reverse isConvert.FromBase64String
returns abyte[]
, so again you need to convert Byte array into string.System.Text.Encoding.Unicode.GetString
does it for you .. . Hope this help you. :thumbsup::thumbsup:Abhishek Sur
My Latest Articles **Create CLR objects in SQL Server 2005 C# Uncommon Keywords Read/Write Excel using OleDB
**Don't forget to click "Good Answer" if you like to.
-
Well,
Convert.ToBase64String
takes a byte array. You need to convert your string toByte
array. You can do it using afor
loop and create the Byte array yourself.System.Text.Encoding.Unicode.GetBytes
does it for you. :cool: On the contrary, the reverse isConvert.FromBase64String
returns abyte[]
, so again you need to convert Byte array into string.System.Text.Encoding.Unicode.GetString
does it for you .. . Hope this help you. :thumbsup::thumbsup:Abhishek Sur
My Latest Articles **Create CLR objects in SQL Server 2005 C# Uncommon Keywords Read/Write Excel using OleDB
**Don't forget to click "Good Answer" if you like to.
Thnx lol i got it....:)
-
Thnx lol i got it....:)
If that answered helps you, then Please don't forget to Click on Good Answer :-D
Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.