| | |
How to Encrypt and Decrypt using C# in window base programme
Please support our C# advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: Jul 2005
Posts: 483
Reputation:
Solved Threads: 19
actually you don't want to be able to decrypt it.
what you do is encrypt the password and save that in the database
when the user logs in, encrypt the password the input on the login screen and compare that to the encrypted password in the database
here is a sample for using MD5 hash to encrypt
oh yeah, and don't forget to use
what you do is encrypt the password and save that in the database
when the user logs in, encrypt the password the input on the login screen and compare that to the encrypted password in the database
here is a sample for using MD5 hash to encrypt
C# Syntax (Toggle Plain Text)
public string Encrypt(string inp) { MD5CryptoServiceProvider hasher = new MD5CryptoServiceProvider(); byte[] tBytes = Encoding.ASCII.GetBytes(inp); byte[] hBytes = hash.ComputeHash(tBytes); StringBuilder sb = new StringBuilder(); for (int c=0;c<hBytes.Length;c++) sb.AppendFormat("{0:x2}",hBytes[c]); return(sb.ToString()); }
oh yeah, and don't forget to use
C# Syntax (Toggle Plain Text)
using System.Security.Cryptography;
•
•
Join Date: May 2007
Posts: 3
Reputation:
Solved Threads: 1
Hi CampKev,
Your below code is working properly. Thanks a lot. But i want to Decrypt it again into normal text. Because when the user log-on again, I can't check if the password is correct or not(bcz the password in my sql server table is encrypted). so i want to Decrypt agn to check. Please give me the code to do.I'll b v.v.thankful to u.
public string Encrypt(string inp) {
MD5CryptoServiceProvider hasher = new MD5CryptoServiceProvider();
byte[] tBytes = Encoding.ASCII.GetBytes(inp);
byte[] hBytes = hash.ComputeHash(tBytes);
StringBuilder sb = new StringBuilder();
for (int c=0;c<hBytes.Length;c++)
sb.AppendFormat("{0:x2}",hBytes[c]);
return(sb.ToString());
}
Your below code is working properly. Thanks a lot. But i want to Decrypt it again into normal text. Because when the user log-on again, I can't check if the password is correct or not(bcz the password in my sql server table is encrypted). so i want to Decrypt agn to check. Please give me the code to do.I'll b v.v.thankful to u.
public string Encrypt(string inp) {
MD5CryptoServiceProvider hasher = new MD5CryptoServiceProvider();
byte[] tBytes = Encoding.ASCII.GetBytes(inp);
byte[] hBytes = hash.ComputeHash(tBytes);
StringBuilder sb = new StringBuilder();
for (int c=0;c<hBytes.Length;c++)
sb.AppendFormat("{0:x2}",hBytes[c]);
return(sb.ToString());
}
![]() |
Similar Threads
- Very basic de/encrypt program (Python)
Other Threads in the C# Forum
- Previous Thread: set current time in textbox
- Next Thread: Datagridview to Database table
Views: 31324 | Replies: 10
| Thread Tools | Search this Thread |
Tag cloud for C#
.net access ado.net algorithm array barchart bitmap box broadcast button c# chat check checkbox class client code color combobox control conversion csharp custom database datagrid datagridview dataset datetime degrees development draganddrop drawing encryption event excel file files form format forms ftp function gcd gdi+ http httpwebrequest image index input install java label list listbox listener login math mouseclick mysql networking object operator path photoshop picturebox pixelinversion post prime programming radians regex remote remoting resource saving serialization server sleep socket sql statistics stream string tcp text textbox thread time timer treeview update usercontrol validation view visualstudio webbrowser windows winforms wpf xml





