Click here to Skip to main content
15,913,669 members
Home / Discussions / C#
   

C#

 
GeneralBest way to calculate hash Pin
Radoslav Bielik22-Aug-04 21:28
Radoslav Bielik22-Aug-04 21:28 
GeneralRe: Best way to calculate hash Pin
Jonathan de Halleux22-Aug-04 23:19
Jonathan de Halleux22-Aug-04 23:19 
GeneralRe: Best way to calculate hash Pin
Radoslav Bielik22-Aug-04 23:37
Radoslav Bielik22-Aug-04 23:37 
GeneralRe: Best way to calculate hash Pin
Jonathan de Halleux22-Aug-04 23:48
Jonathan de Halleux22-Aug-04 23:48 
GeneralRe: Best way to calculate hash Pin
Radoslav Bielik23-Aug-04 0:01
Radoslav Bielik23-Aug-04 0:01 
GeneralRe: Best way to calculate hash Pin
Heath Stewart23-Aug-04 6:22
protectorHeath Stewart23-Aug-04 6:22 
GeneralRe: Best way to calculate hash Pin
Radoslav Bielik23-Aug-04 8:48
Radoslav Bielik23-Aug-04 8:48 
GeneralRe: Best way to calculate hash Pin
Heath Stewart23-Aug-04 6:30
protectorHeath Stewart23-Aug-04 6:30 
Ask yourself - do you want faster code or do you want to write less code? Using FormsAuthentication.HashPasswordForStoringInConfigFile is quicker to use (albeit a long method name!) but using the MD5 class (or MD5CryptoServiceProvider - it's really the same thing) will result in a little less code (not much, but will save a few extra IL instructions):
MD5 md5 = MD5.Create();
byte[] buffer = Encoding.UTF8.GetBytes(inputString);
byte[] hash = md5.ComputeHash(buffer);
StringBuilder sb = new StringBuilder(hash.Length * 2);
foreach (byte b in buffer)
  sb.Append(b.ToString("x2");
return sb.ToString();
FormsAuthentication.HashPasswordForStoringInConfigFile adds a few steps for comparing the string you pass ("md5" or "sha1").

 

Software Design Engineer
Developer Division Sustained Engineering, Microsoft
My Articles
GeneralRe: Best way to calculate hash Pin
Radoslav Bielik23-Aug-04 8:53
Radoslav Bielik23-Aug-04 8:53 
GeneralSorting an Arraylist Pin
malik1022-Aug-04 19:59
malik1022-Aug-04 19:59 
GeneralRe: Sorting an Arraylist Pin
sreejith ss nair22-Aug-04 20:11
sreejith ss nair22-Aug-04 20:11 
Generalproblem implementing special gradient Pin
obby22-Aug-04 19:52
obby22-Aug-04 19:52 
GeneralRe: problem implementing special gradient Pin
leppie22-Aug-04 21:03
leppie22-Aug-04 21:03 
GeneralProblem in HTTP POST Pin
khchan22-Aug-04 18:49
khchan22-Aug-04 18:49 
GeneralRe: Problem in HTTP POST Pin
LongRange.Shooter23-Aug-04 7:40
LongRange.Shooter23-Aug-04 7:40 
GeneralWinForms -> Submit (POST) to a web page and get results Pin
theoutlander22-Aug-04 18:36
theoutlander22-Aug-04 18:36 
GeneralRe: WinForms -> Submit (POST) to a web page and get results Pin
Mazdak22-Aug-04 19:30
Mazdak22-Aug-04 19:30 
GeneralProfessional database advice Pin
steve_rm22-Aug-04 18:03
steve_rm22-Aug-04 18:03 
GeneralRe: Professional database advice Pin
Mazdak22-Aug-04 19:18
Mazdak22-Aug-04 19:18 
GeneralRe: Professional database advice Pin
steve_rm23-Aug-04 5:25
steve_rm23-Aug-04 5:25 
GeneralMarshalling struct with array member Pin
rana7422-Aug-04 15:41
rana7422-Aug-04 15:41 
GeneralRe: Marshalling struct with array member Pin
leppie23-Aug-04 3:51
leppie23-Aug-04 3:51 
QuestionHow to export data from datagrid to excel? Pin
tzewei22-Aug-04 14:15
tzewei22-Aug-04 14:15 
AnswerRe: How to export data from datagrid to excel? Pin
Jay Shankar22-Aug-04 16:49
Jay Shankar22-Aug-04 16:49 
GeneralRe: How to export data from datagrid to excel? Pin
tzewei22-Aug-04 20:29
tzewei22-Aug-04 20:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.