This is an example showing a proper hashing algorithm for hashing passwords for storage. Make sure that you store the salt for the password as well. Otherwise, there is no way to get it back. You can tweak the iterations and keylength variables as needed. As future CPU (and GPUs) get faster, you will have to change the iterations.