2

Using BCrypt technology to store the password into database as a hash. Though it may be bit slow compared to fast hashing algorithm like MD5, SHA-1, etc, we decided to go as security is more important.

In .Net I have implemented using http://bcrypt.codeplex.com/

BCrypt.Net.BCrypt.HashPassword("Password", BCrypt.Net.BCrypt.GenerateSalt(12));

In our site where administrator will create the user-name and password for new user.

There is no issue in storing hashed password. But if admin want to update the password he need to see the old password. I dont see any method that decry-pt the hashed value stored in DB in Bcrypt.Net.

Is there any way to generate text from Bcrypt hashed password? However I agree that it should not be possible, but there are some scenario we are put into to do this :(

Update: I decided to use a default password that is stored in some table as plain text and hash that text and store as a password for a user. When user login into the site he will be forced to change the password until he reset. Will this sounds good?

Murali Murugesan
  • 22,423
  • 17
  • 73
  • 120
  • 1
    Please search first. This has been asked/conjectured and answered *many* times before. –  Mar 23 '13 at 05:59
  • http://stackoverflow.com/questions/330207/how-come-md5-hash-values-are-not-reversible?lq=1 , http://stackoverflow.com/questions/1038307/what-are-the-important-points-about-cryptographic-hash-functions?lq=1 , http://stackoverflow.com/questions/2717950/how-can-it-be-impossible-to-decrypt-an-md5-hash?lq=1 , http://stackoverflow.com/questions/7545431/changing-the-hashing-function-on-a-pre-existing-database –  Mar 23 '13 at 06:00
  • If you need the old password, do 1 of 3 things: store the raw non-hashed string, write it on a sticky-note, or my favorite: change your design so you don't need it. – Dan Mar 23 '13 at 06:01
  • 1
    Don't require the old password to be known to anybody besides the creator of that password. Until you are in compliance with this, I don't think you have a good design. – Dan Mar 23 '13 at 06:07
  • @Murali Read the linked questions. This "default password" idea sounds bad. Why have it in plain text at all? –  Mar 23 '13 at 06:08
  • @pst, what could be the best way of generating user for the site with password? Is it ok if i generate some random password and send to user? – Murali Murugesan Mar 23 '13 at 06:19
  • @Murali Most registration systems require the user to specify an initial password. If this is not acceptable, then a [*nonce*](http://en.wikipedia.org/wiki/Cryptographic_nonce) (not a "password") can be used in the "Finish Registration and Set A Password" link. This is how "Reset Password" links sent to e-mail accounts work (or should work). –  Mar 23 '13 at 06:30
  • @pst the problem is Administrator register the user. This system is used by a hospital staff for booking appointment. At initial setup admin will create user names and pwds for the staffs and mail them with the application link. I am thinking of a good solution for this to send a pwd that stored as a hashed text. This will be hosted as a multitenant application and exposed in Internet – Murali Murugesan Mar 23 '13 at 06:40
  • Please **read** my comment and follow the link. –  Mar 23 '13 at 06:40

1 Answers1

15

Cryptographic hashing, by design, is a one-way function. It is precisely the intent of the hashing function to be infeasible to reverse. In addition, multiple inputs can hash to the same output.

Requiring access to the old password in order to set a new password is indicative of a flawed design. Why, exactly, do you need access to the old password in plaintext in order to update the password?

Jared Ng
  • 4,891
  • 2
  • 19
  • 18