Click here to Skip to main content
15,918,177 members
Home / Discussions / C#
   

C#

 
QuestionCalling an OpenCV function Pin
E6AD27-Aug-05 10:30
E6AD27-Aug-05 10:30 
AnswerRe: Calling an OpenCV function Pin
Mohamad Al Husseiny27-Aug-05 11:29
Mohamad Al Husseiny27-Aug-05 11:29 
GeneralRe: Calling an OpenCV function Pin
Anonymous27-Aug-05 12:25
Anonymous27-Aug-05 12:25 
QuestionTutorial on writing and reading configuration file Pin
Fredy27-Aug-05 10:06
Fredy27-Aug-05 10:06 
AnswerRe: Tutorial on writing and reading configuration file Pin
Mohamad Al Husseiny27-Aug-05 10:23
Mohamad Al Husseiny27-Aug-05 10:23 
AnswerRe: Tutorial on writing and reading configuration file Pin
Fredy27-Aug-05 10:58
Fredy27-Aug-05 10:58 
QuestionEncryption/Decryption Pin
just4ulove727-Aug-05 7:16
just4ulove727-Aug-05 7:16 
AnswerRe: Encryption/Decryption Pin
Dave Shaw27-Aug-05 8:33
Dave Shaw27-Aug-05 8:33 
Hi,

If you want to store a password in database, I suggest you use a 'One-Way Hash' algorythm.

These are un-reversable encryption algorythms, hence the name one-way. Then you follow these steps to authenticate your users:

1. User Registers, Username and Hashed Password are stored in DB.
2. User types in Username and Password. P = password
3. The Software encrypts the Users Password with a One-Way Hash. P1 = Hash(P)
4. The Software queries the database and finds the password of the user (Storing Hashed in the database). P2 = database_pass
5. If the Hashed Pass in the DB and Hashed Pass the user typed in Match, Allow Login. If P1 == P2 then Login else Fail (remeber P1 = Hash(P))

Try this code to generate a one-way hash of a password.

-------------------------------------------------------------------------------

private Byte[] GetByteArray( String originalString )
{
Char[] charArray = originalString.ToCharArray();
Byte[] byteArray = new Byte[charArray.Length];
for ( int i=0; i<byteArray.Length; i++ )
{
byteArray[i] = Convert.ToByte( charArray[ i ] );
}
return byteArray;
}

/// <summary>
/// Creates a one-way SHA1 hash of the pt string
/// </summary>
/// <param name="pt">Plaintext to Hash</param>
/// <returns>Ciphertext string</returns>
public string Hash(string pt)
{
//Implement SHA1 Hashing Algorythm (40 Bytes / 320 bits)
byte[] data = new byte[40];
byte[] hash = new byte[40];

while (pt.Length % 4 != 0) pt += "g";

data = Convert.FromBase64String(pt);

SHA1 sha = new SHA1CryptoServiceProvider();
hash = sha.ComputeHash(data);

return Convert.ToBase64String(hash);
}

-------------------------------------------------------------------------------


Thanx!

Dave Shaw

History admires the wise, but elevates the brave. - Edmund Morris
GeneralRe: Encryption/Decryption Pin
just4ulove727-Aug-05 8:37
just4ulove727-Aug-05 8:37 
QuestionDynamicaly moving controls at runtime Pin
Mutty27-Aug-05 6:13
Mutty27-Aug-05 6:13 
AnswerRe: Dynamicaly moving controls at runtime Pin
[Marc]27-Aug-05 6:18
[Marc]27-Aug-05 6:18 
GeneralRe: Dynamicaly moving controls at runtime Pin
Mutty27-Aug-05 6:49
Mutty27-Aug-05 6:49 
AnswerRe: Dynamicaly moving controls at runtime Pin
gnjunge27-Aug-05 7:54
gnjunge27-Aug-05 7:54 
QuestionFind Windows version remotely Pin
notacake27-Aug-05 4:06
notacake27-Aug-05 4:06 
AnswerRe: Find Windows version remotely Pin
Matt Gerrans27-Aug-05 7:02
Matt Gerrans27-Aug-05 7:02 
Questionwhat differences came from 'component' and 'windows form'? Pin
Sasuko27-Aug-05 2:49
Sasuko27-Aug-05 2:49 
QuestionLine Count and Byte Count Pin
Mridang Agarwalla27-Aug-05 2:45
Mridang Agarwalla27-Aug-05 2:45 
AnswerRe: Line Count and Byte Count Pin
FalkoD27-Aug-05 3:22
FalkoD27-Aug-05 3:22 
AnswerRe: Line Count and Byte Count Pin
Mohamad Al Husseiny27-Aug-05 3:39
Mohamad Al Husseiny27-Aug-05 3:39 
GeneralRe: Line Count and Byte Count Pin
Lord Kixdemp27-Aug-05 12:58
Lord Kixdemp27-Aug-05 12:58 
AnswerRe: Line Count and Byte Count Pin
Guffa27-Aug-05 5:28
Guffa27-Aug-05 5:28 
NewsRe: Line Count and Byte Count Pin
Rei Miyasaka29-Aug-05 13:04
Rei Miyasaka29-Aug-05 13:04 
QuestionC# and Excel Pin
surfman1927-Aug-05 0:39
surfman1927-Aug-05 0:39 
AnswerRe: C# and Excel Pin
Mohamad Al Husseiny27-Aug-05 1:27
Mohamad Al Husseiny27-Aug-05 1:27 
GeneralRe: C# and Excel Pin
surfman1927-Aug-05 1:44
surfman1927-Aug-05 1:44 

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.