Viewing "Geetha's" Blogs

Jun
29

How do we protect passwords in web pages

By Geetha Govindaswamy | Posted on 2007 2:18 PM | Comments on 2 comments

While developing web pages, we need to avoid storing user passwords either in plaintext or encrypted format. Instead, store password hashes with salt. Ensure only required accounts have the access to user store database. Store your credential database on a physically separate server from your Web server.

Solution:

Passwords should not be stored encrypted, but rather they should be stored HASHED or DIGESTED. To validate a username/password add some magic "salt" and hash it. This results in a fixed length string of some bytes of data. We compare that to the stored hash and if they match – user is validated.

For examples:

Using C#/VB.NET: 

http://www.obviex.com/samples/hash.aspx

Using ORACLE:

declare

function digest( p_username in varchar2, p_password in varchar2 ) return varchar2

is

begin

return ltrim( to_char( dbms_utility.get_hash_value(

upper(p_username)||'/'||upper(p_password), 1000000000, power(2,30) ),rpad( 'X',29,'X')||'X' ) );

end digest;

begin

for x in ( select username from all_users where rownum < 20 )

loop

dbms_output.put_line( 'User: ' || rpad( x.username , 30 ) ||

' digest: ' || digest( x.username, 'TIGER' ) );

end loop;

end;

/

Results:

User: SYS  digest: 6869FA1A

User: SYSTEM digest: 79F08AFC

User: SCOTT digest: 4307767C

This post is categorized under: ASP.Net, Website Work

  • Blog Tools:
  • Del.cio.us
  • Google
  • Stumbleupon
  • Yahoo
  1. Geetha Govindaswamy said on 7/11/2008 11:04 AM Approve this comment

    Test

  2. Geetha Govindaswamy said on 7/15/2008 2:13 PM Approve this comment

    test

Leave a Comment

* Name:
* Email: (will not be displayed)
URL:
* Comment:
Enter the code shown:

  • Anonymous Comments Are Enabled
  • Moderated Comments Are Enabled
  • Fields marked with an asterisk (*) are required.
  • a, strong, em and code tags are allowed. Line breaks and paragraphs are automatically generated. Inappropriate comments will be either deleted or edited.