How would you add salt to your existing password hashes?

前端 未结 8 1685
心在旅途
心在旅途 2021-02-08 06:08

I have a database of hashed passwords that had no salt added before they were hashed. I want to add salt to new passwords. Obviously I can\'t re-hash the existing ones.

<
8条回答
  •  逝去的感伤
    2021-02-08 06:26

    Create a new field in you're database named "salted" with a type of true/false (or whatever the equivalent is in your DBMS). Set all the values to false for the existing hashes. Whenever a new, salted, hash is added, set the "salted" field to true.

    Then, all you have to do is handle the two types of hashes differently in your code.

    This is more of a general solution than a specific one, but it should solve your problem.

提交回复
热议问题