Created
January 22, 2012 04:04
-
-
Save weatheredwatcher/1655410 to your computer and use it in GitHub Desktop.
A Codeigniter helper for encrypting a string (like a password) using blowfish
This file contains hidden or 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 | |
function bcrypt($password, $salt) | |
{ | |
//Checks to see if blowfish is installed on the server | |
CRYPT_BLOWFISH or die ('No Blowfish found.'); | |
$password = $password; | |
$salt = $salt; | |
//This sets up the Blowfish prefix and end | |
$Blowfish_Pre = '$2a$05$'; //this instructs blowfish to encrypt 5 passes | |
$Blowfish_End = '$'; | |
$bcrypt_salt = $Blowfish_Pre . $salt . $Blowfish_End; | |
$hashed_password = crypt($password, $bcrypt_salt); | |
include 'application/helpers/bcrypt_helper.php'; | |
return $hashed_password; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment