COPYRIGHT RESERVED 2009 BY MAX TSAI



Visit Max Tsai at Facebook | Twitter | atom

Friday, February 20, 2009

Regeneratable Passwords, but still Safe (I hope so)

It comes up a need to create regenerate'ble passwords for users, but need to made sure no one else can regenerate or decode it. Here is the idea:
  1. Using user id, i.e. maxtheman
  2. Add a secret salt in the beginning and the end of the User ID, for instance,
    $preSalt="aloha";
    $postSalt="goodbye";
    $Token = $preSalt + $UID + $postSalt;
    for our example, it is "alohamaxthemangoodbye"
  3. Hash it with md5 (just b/c there is a md5 function everywhere; so, I use it):
    md5($Token) that is
    md5("alohamaxthemangoodbye") = ee15d0b677a8ed1b25e470fe888958d7
  4. Then, we chop the word -- any part you like thefirst8letters("ee15d0b677a8ed1b25e470fe888958d7") = ee15d0b6
Use ee15d0b6 as the assigned user password and the user can not change it. You can enhance the security by changing the Salts as often as you want.

How do you think?

No comments:

Post a Comment