Click here to Skip to main content
15,883,797 members
Home / Discussions / C#
   

C#

 
GeneralRe: Future C# Language Features announced Pin
SimonS12-Nov-02 20:00
SimonS12-Nov-02 20:00 
GeneralUserControl accessing CodeBehind Pin
Steve McLenithan11-Nov-02 7:14
Steve McLenithan11-Nov-02 7:14 
GeneralRe: UserControl accessing CodeBehind Pin
leppie11-Nov-02 8:25
leppie11-Nov-02 8:25 
GeneralRe: UserControl accessing CodeBehind Pin
Steve McLenithan11-Nov-02 11:18
Steve McLenithan11-Nov-02 11:18 
Questionbinding to rich text controls...howto? Pin
LongRange.Shooter11-Nov-02 4:37
LongRange.Shooter11-Nov-02 4:37 
AnswerRe: binding to rich text controls...howto? Pin
James T. Johnson11-Nov-02 4:41
James T. Johnson11-Nov-02 4:41 
GeneralRe: binding to rich text controls...howto? Pin
LongRange.Shooter11-Nov-02 9:27
LongRange.Shooter11-Nov-02 9:27 
GeneralPassword Encryption Pin
Derek Lakin11-Nov-02 3:50
Derek Lakin11-Nov-02 3:50 
I use the code described below to one-way hash a supplied user's password to verify it against the one-way hashed password stored in a database.
While the code works and provides the functionality I am looking for I am not convinced that it does it in the quickest/most elegant/most sensible/safest way.
Any ideas for improvement?

// Convert the supplied password into a char array
char[] password = new char[50];
System.IO.StringReader reader = new System.IO.StringReader(this.textBoxPassword);
reader.Read(password, 0, 50);

// Copy the char array into a byte array for encryption
byte[] bPassword = new byte[50];
for(int i = 0; i < 50; i++)
{
	bPassword[i] = (byte)password[i]);
}

// Hash the password
System.Security.Cryptography.SHA1 shaM = new System.Security.Cryptography.SHA1Managed();
byte[] hash = shaM.ComputeHash(bPassword);

// Convert the hash into a char array
char[] cHash = new char[hash.Length];
for(int i = 0; i < hash.Length; i++)
{
	cHash[i] = (char)hash[i];
}

// Create a string from the hash for db verification
string hashword = new string(cHash);

// ... Perform db verification


Derek Lakin.
I wish I was what I thought I was when I wished I was what I am.

Salamander Software Ltd.
GeneralRe: Password Encryption Pin
David Stone11-Nov-02 4:49
sitebuilderDavid Stone11-Nov-02 4:49 
GeneralRe: Password Encryption Pin
Derek Lakin11-Nov-02 19:55
Derek Lakin11-Nov-02 19:55 
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 
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 

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.