Click here to Skip to main content
15,889,595 members
Home / Discussions / C#
   

C#

 
GeneralRe: Password Encryption Pin
David Stone12-Nov-02 4:42
sitebuilderDavid Stone12-Nov-02 4:42 
GeneralRe: Password Encryption Pin
Derek Lakin12-Nov-02 19:56
Derek Lakin12-Nov-02 19:56 
GeneralRe: Password Encryption Pin
Pete Bassett11-Nov-02 4:59
Pete Bassett11-Nov-02 4:59 
AHHH. Damn and blast. David beat me to it.

Yeah, hes right. Yours isn't the best way of doing it.

public string test2(string strBoxPassword)
{
	// Copy the char array into a byte array for encryption
	byte[] bPassword = System.Text.Encoding.Default.GetBytes(strBoxPassword);

	// Hash the password
	System.Security.Cryptography.SHA1 shaM = new System.Security.Cryptography.SHA1Managed();

	byte[] hash = shaM.ComputeHash(bPassword);

	return System.Text.Encoding.Default.GetString(hash);
}


Note that this and Davids reply are pretty similar except he excplicitly speficies the Unicode encoder. However, please note that both these methods WILL NOT return the same hash as your old method. The reason beeing is that you hard code 50 characters in the source byte array no matter what the actual length is. Our methods only hash the actual contents of the data and no extra trailing bytes.

Therefore if you already have hashes in your DB based on the originial code your probably going to have to either stick with what you have or re generate all the hashes...

Pete

Insert Sig. Here!
GeneralRe: Password Encryption Pin
David Stone11-Nov-02 4:58
sitebuilderDavid Stone11-Nov-02 4:58 
GeneralRe: Password Encryption Pin
leppie11-Nov-02 6:15
leppie11-Nov-02 6:15 
GeneralRe: Password Encryption Pin
David Stone11-Nov-02 9:23
sitebuilderDavid Stone11-Nov-02 9:23 
GeneralRe: Password Encryption Pin
leppie11-Nov-02 9:58
leppie11-Nov-02 9:58 
GeneralRe: Password Encryption Pin
David Stone11-Nov-02 10:47
sitebuilderDavid Stone11-Nov-02 10:47 
GeneralRe: Password Encryption Pin
Derek Lakin11-Nov-02 19:52
Derek Lakin11-Nov-02 19:52 
GeneralSome inherited form questions.... Pin
LongRange.Shooter11-Nov-02 3:44
LongRange.Shooter11-Nov-02 3:44 
Generalidc_arrow and C# Pin
Senkwe Chanda11-Nov-02 2:20
Senkwe Chanda11-Nov-02 2:20 
GeneralRe: idc_arrow and C# Pin
Stephane Rodriguez.11-Nov-02 3:01
Stephane Rodriguez.11-Nov-02 3:01 
GeneralRe: idc_arrow and C# Pin
Senkwe Chanda11-Nov-02 4:12
Senkwe Chanda11-Nov-02 4:12 
GeneralRe: idc_arrow and C# Pin
Stephane Rodriguez.11-Nov-02 4:13
Stephane Rodriguez.11-Nov-02 4:13 
GeneralRe: idc_arrow and C# Pin
Senkwe Chanda11-Nov-02 18:39
Senkwe Chanda11-Nov-02 18:39 
GeneralRe: idc_arrow and C# Pin
Anonymous11-Nov-02 18:56
Anonymous11-Nov-02 18:56 
GeneralRe: idc_arrow and C# Pin
Senkwe Chanda11-Nov-02 19:47
Senkwe Chanda11-Nov-02 19:47 
QuestionDataGrid ??? Pin
Christian Graus11-Nov-02 0:05
protectorChristian Graus11-Nov-02 0:05 
AnswerRe: DataGrid ??? Pin
James T. Johnson11-Nov-02 3:00
James T. Johnson11-Nov-02 3:00 
AnswerRe: DataGrid ??? Pin
leppie11-Nov-02 6:27
leppie11-Nov-02 6:27 
General.NET Training Institute Pin
ReachAnshul10-Nov-02 19:30
ReachAnshul10-Nov-02 19:30 
GeneralRe: .NET Training Institute Pin
Christian Graus10-Nov-02 19:43
protectorChristian Graus10-Nov-02 19:43 
GeneralBindingsCollection Pin
Alan Todtenkopf9-Nov-02 11:19
Alan Todtenkopf9-Nov-02 11:19 
GeneralRe: BindingsCollection Pin
James T. Johnson9-Nov-02 11:25
James T. Johnson9-Nov-02 11:25 
GeneralDownloading files with Webrequest Pin
Anonymous9-Nov-02 7:40
Anonymous9-Nov-02 7:40 

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.