To change the password length in db, it is not easy for us. It is huge application and we have used password field in various aspx, pages and store procedure.
Please advise
Main Topics
Browse All TopicsI am using form based authentication. I have login table where password field length is varchar(25). I want to store encrypted in password field. I review various good articles, some of them mentioned below
http://msdn.microsoft.com/
http://www.dotnetspark.com
All this codes are good but their encrypted password length are more than 25 character. My problem here I cant change the length password field. Please someone suggest How can I generate 25 character encrypted length?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
I find 1 discussion thread and tested. Seems to look good, but still I am not comfortable. Here is the url
http://www.dreamincode.net
I'm not sure of the thread here...
if you want to know how to do encryption and decryption here is another post..
http://www.experts-exchang
but the posts you mentioned in your question are good as well...
What exactly are you not comfortable with?
CPG
COde mentioned in http://www.dreamincode.net
right it sucks.
like my pervious post >>Unless you want to write your own encryption...which is strongly suggested not to do.
it's custom. but it's for a school project so I guess thats ok for that implementation.
You need to use something like rijndael encryption, AES. like the sample you had and also the link I just provided.
Let me know if you need further assistance.
CPG
If you use a hash function like SHA-1 to store the passwords, the generated digest will be 20 bytes long. You should be able to store that in your varchar(25).
Have a look at the snippet I included below which should illustrate what I mean. The method HashPasswordForStoring always returns a 20 character string which should be unique to the input you give it - as long as you make sure to specify the right input encoding as well, so there is no misinterpretation of the password before generating the SHA-1 digest.
I am using a single byte encoding (ISO-8859-1) to convert the digest into a string, as this should ensure that each of the 20 bytes is translated into a single unique character. If you use the same approach when comparing passwords for login attempts, it should work.
Right, this is hashing, not encryption. If you do it this way, you will only be able to use the stored values to evaluate login attempts - I didn't realize you needed to be able to get back the password in its original form. I would normally consider it good practice to store only the hashed versions of user passwords, but I may not fully understand your problem domain.
Another option might be to create a new table where you store the passwords in a column with the right datatype. Then you give each password in the new table a unique primary key and store that in the original table instead of the password itself. Similar to a traditional foreign key relationship.
That way you can look up the encrypted password string in the new table when you need it, using the key stored in the legacy table. It will mean a small (but most likely acceptable) performance penalty on the database level, as you have to do an extra query, however, it should avoid any compromises on security.
Kristain
Here is the proceddure I have tested successfully. I am storing the hashing for password in password field. Now Once used enter his credentail like username and password (as plain text), first I converted password into hash value and then compared password from sql table, if it mach thne he will be able to logged into table otherwise he will get erroe validation message. I am also matchining Username, so there shuld be no duplicate value in the sql table.
What do you think is it correct approach?
That was the idea, yes. Doing it that way, it is not possible to obtain the original passwords, even if someone was to get access to your database. It should provide better security than storing encrypted strings, which could be decrypted by anyone who obtains the necessary keys, or is able to otherwise break the encryption.
You have to make sure to watch out for any encoding issues when storing the hashed password in the database. If the string is changed in any way, either when you first insert it or when you later retrieve it back, then the evalutation of credentials provided by the user will always fail.
It should be fairly simple to test I presume.
Business Accounts
Answer for Membership
by: copyPasteGhostPosted on 2009-09-30 at 07:14:28ID: 25459049
is there a reason why the password length in your DB can't be changed to 50?
a regular MD5 encryption is 32 characters...I've never heard of a 25 character encrypted string. Unless you want to write your own encryption...which a strongly suggested not to do.
CPG