Hi, I have a text box, a label and a button.I need to encrypt and display the values entered in the textbox in my label.I referred this link.But am not able to implement it as i am a newbie to c# programming.Kindly help me for this with the correct code using
the encrypt function in this link. Encryption/Decryption Function in .NET using the TripleDESCryptoServiceProvider
Class[^] help me friends with correct code for button click...
i am a newbie to c#.i dono much about hw to use the code in the link which i ve posted. I need to refer that link and prepare my code in that encrytion decryption methd... Refer that link and write and give me correct coding for button click in my asp form.
i need md5 encryption . Ur code is using a different type of encryption i hope..
i dono to call these methods and publishing output in my label.thats the main problem.guide me how to get value from the methods and display as output in a label when i click the submit button.
ajithkumar90
Member
1 Points
24 Posts
Encryption decryption of user passwords in C#
Aug 07, 2012 10:50 AM|LINK
Hi,
I have a text box, a label and a button.I need to encrypt and display the values entered in the textbox in my label.I referred this link.But am not able to implement it as i am a newbie to c# programming.Kindly help me for this with the correct code using the encrypt function in this link.
Encryption/Decryption Function in .NET using the TripleDESCryptoServiceProvider Class[^]
help me friends with correct code for button click...
net
Prashant Kum...
Star
12528 Points
2024 Posts
Re: Encryption decryption of user passwords in C#
Aug 07, 2012 10:55 AM|LINK
Can you post your code?
net
Vivek J Pand...
Participant
922 Points
257 Posts
Re: Encryption decryption of user passwords in C#
Aug 07, 2012 11:01 AM|LINK
try this
http://forums.asp.net/p/1238171/2258386.aspx
const string DESKey = "AQWSEDRF"; const string DESIV = "HGFEDCBA"; public static string DESDecrypt(string stringToDecrypt)//Decrypt the content { byte[] key; byte[] IV; byte[] inputByteArray; try { key = Convert2ByteArray(DESKey); IV = Convert2ByteArray(DESIV); int len = stringToDecrypt.Length; inputByteArray = Convert.FromBase64String(stringToDecrypt); DESCryptoServiceProvider des = new DESCryptoServiceProvider(); MemoryStream ms = new MemoryStream(); CryptoStream cs = new CryptoStream(ms, des.CreateDecryptor(key, IV), CryptoStreamMode.Write); cs.Write(inputByteArray, 0, inputByteArray.Length); cs.FlushFinalBlock(); Encoding encoding = Encoding.UTF8; return encoding.GetString(ms.ToArray()); } catch (System.Exception ex) { throw ex; } } public static string DESEncrypt(string stringToEncrypt)// Encrypt the content { byte[] key; byte[] IV; byte[] inputByteArray; try { key = Convert2ByteArray(DESKey); IV = Convert2ByteArray(DESIV); inputByteArray = Encoding.UTF8.GetBytes(stringToEncrypt); DESCryptoServiceProvider des = new DESCryptoServiceProvider(); MemoryStream ms = new MemoryStream(); CryptoStream cs = new CryptoStream(ms, des.CreateEncryptor(key, IV), CryptoStreamMode.Write); cs.Write(inputByteArray, 0, inputByteArray.Length); cs.FlushFinalBlock(); return Convert.ToBase64String(ms.ToArray()); } catch (System.Exception ex) { throw ex; } } static byte[] Convert2ByteArray(string strInput) { int intCounter; char[] arrChar; arrChar = strInput.ToCharArray(); byte[] arrByte = new byte[arrChar.Length]; for (intCounter = 0; intCounter <= arrByte.Length - 1; intCounter++) arrByte[intCounter] = Convert.ToByte(arrChar[intCounter]); return arrByte; }--Vivek
ajithkumar90
Member
1 Points
24 Posts
Re: Encryption decryption of user passwords in C#
Aug 07, 2012 11:07 AM|LINK
i am a newbie to c#.i dono much about hw to use the code in the link which i ve posted. I need to refer that link and prepare my code in that encrytion decryption methd... Refer that link and write and give me correct coding for button click in my asp form.
http://www.codeproject.com/Tips/306620/Encryption-Decryption-Function-in-Net-using-MD5Cry
Vivek J Pand...
Participant
922 Points
257 Posts
Re: Encryption decryption of user passwords in C#
Aug 07, 2012 11:10 AM|LINK
are you getting any error or facing any issue @ debugging .. share more details
--Vivek
ajithkumar90
Member
1 Points
24 Posts
Re: Encryption decryption of user passwords in C#
Aug 07, 2012 11:16 AM|LINK
i need md5 encryption . Ur code is using a different type of encryption i hope..
i dono to call these methods and publishing output in my label.thats the main problem.guide me how to get value from the methods and display as output in a label when i click the submit button.
Ramesh Chand...
Star
12922 Points
2672 Posts
Re: Encryption decryption of user passwords in C#
Aug 07, 2012 11:17 AM|LINK
MD5 is a one way encription technique. you can't achive encryption/decryption with md5.
Vivek J Pand...
Participant
922 Points
257 Posts
Re: Encryption decryption of user passwords in C#
Aug 07, 2012 11:19 AM|LINK
Dim security As Web.Security.FormsAuthentication
security.HashPasswordForStoringInConfigFile("password", "md5").GetHashCode()
--Vivek
Vivek J Pand...
Participant
922 Points
257 Posts
Re: Encryption decryption of user passwords in C#
Aug 07, 2012 11:20 AM|LINK
try this
http://msdn.microsoft.com/en-us/library/system.security.cryptography.md5.aspx
for more details
--Vivek
ajithkumar90
Member
1 Points
24 Posts
Re: Encryption decryption of user passwords in C#
Aug 07, 2012 11:23 AM|LINK
http://www.codeproject.com/Tips/306620/Encryption-Decryption-Function-in-Net-using-MD5Cryi hope they ve used for encrpt and decrpt in this.! i want a code for my application based on this function..