/* - Password Encoder - Encodes a password so it cannot be converted back into plain text by anyone that has access to the database. $password - The plain text password that was entered by the user for encoding $salt - Optional but recommended, "salts" the password to make it even harder to be decoded. Can be generated with the function generateSalt() $hashType - Default is sha512, the hashing algorithm to use between: sha1, sha256, sha512, ripemd160 */ public function encodePassword($password, $salt = '', $hashType = 'sha512') { if ($hashType != "sha1" && $hashType != "sha256" && $hashType != "sha512" && $hashType != "ripemd160") $hashType = "sha512"; if ($salt == '') $password = hash($hashType, $password); else $password = hash($hashType, $salt . $password . $salt); return $password; }