Created
January 26, 2016 14:37
-
-
Save macloo/c26478ebae8e6163910d to your computer and use it in GitHub Desktop.
Encrypting passwords with PHP for MySQL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// this is a partial, nonworking file | |
$salt1 = "qm&h*"; | |
$salt2 = "pg!@"; | |
$first_name = "Bill"; | |
$last_name = "Smith"; | |
$username = "bsmith"; | |
$password = "secret"; | |
$token = hash('ripemd128', "$salt1$password$salt2"); | |
$query = "INSERT INTO users (first_name, last_name, username, password) VALUES ('$first_name', '$last_name', '$username', '$token')"; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Resource:
http://php.net/manual/en/function.hash.php
Code derived from chapter 12, "Cookies, Sessions, and Authentication," in:
http://lpmj.net/4thedition/