Skip to content

Instantly share code, notes, and snippets.

@macloo
Created January 26, 2016 14:37
Show Gist options
  • Save macloo/c26478ebae8e6163910d to your computer and use it in GitHub Desktop.
Save macloo/c26478ebae8e6163910d to your computer and use it in GitHub Desktop.
Encrypting passwords with PHP for MySQL
<?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')";
?>
@macloo
Copy link
Author

macloo commented Jan 26, 2016

Resource:

http://php.net/manual/en/function.hash.php

Code derived from chapter 12, "Cookies, Sessions, and Authentication," in:
http://lpmj.net/4thedition/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment