One way Encryption

How to encrypt my Password from front end to sqlserver2008 using C#

Page 1 of 1

2 Replies - 13476 Views - Last Post: 04 September 2009 - 06:14 AM Rate Topic: ***-- 2 Votes

#1 edwingurusingh  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 03-September 09

One way Encryption

Post icon  Posted 03 September 2009 - 11:31 PM

Hai ...

I want to encrypt my Password & I stored that it into sqlserver2008 using C# in Asp.net . But the condition is one way Encryption, Not decryptable..In sqlserver no one must understand my password
If any one Know answer about my question,Please kindly help me as soon as possible

This post has been edited by edwingurusingh: 03 September 2009 - 11:35 PM

Is This A Good Question/Topic? 0
  • +

Replies To: One way Encryption

#2 MentalFloss  Icon User is offline

  • .
  • member icon

Reputation: 577
  • View blog
  • Posts: 1,500
  • Joined: 02-September 09

Re: One way Encryption

Posted 04 September 2009 - 04:35 AM

View Postedwingurusingh, on 3 Sep, 2009 - 10:31 PM, said:

Hai ...

I want to encrypt my Password & I stored that it into sqlserver2008 using C# in Asp.net . But the condition is one way Encryption, Not decryptable..In sqlserver no one must understand my password
If any one Know answer about my question,Please kindly help me as soon as possible


So, essentially what you want to do for login:
1. User logs in with User Name and Password.
2. Provided password is hashed along with the user name as salt.
3. Generated salted hash is compared against the existing table entry.
4. If matched, log in.

And change password:
1. User authenticates via same steps as the login.
2. Once authenticated, newly provided password is hashed with user name as salt.
3. This new hash will be stored to the table (possibly overwriting old value, but maybe not)

Hopefully this helps.
Was This Post Helpful? 0
  • +
  • -

#3 lesPaul456  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 174
  • View blog
  • Posts: 729
  • Joined: 16-April 09

Re: One way Encryption

Posted 04 September 2009 - 06:14 AM

MentalFloss summed it up pretty well.

Here's some example code on hashing a password. As MentalFloss pointed out, you should add a salt to ensure that the hashed password is unique. In order for this code to compile, you need to add System.Security.Cryptography to your namespaces.

 static string HashPassword(string pasword)
 {
            byte[] arrbyte = new byte[pasword.Length];
            SHA256 hash = new SHA256CryptoServiceProvider();
            arrbyte = hash.ComputeHash(Encoding.UTF8.GetBytes(pasword));
            return Convert.ToBase64String(arrbyte);
 }



Hope this helps!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1