Skip to content

Instantly share code, notes, and snippets.

@weatheredwatcher
Created January 22, 2012 04:04
Show Gist options
  • Save weatheredwatcher/1655410 to your computer and use it in GitHub Desktop.
Save weatheredwatcher/1655410 to your computer and use it in GitHub Desktop.
A Codeigniter helper for encrypting a string (like a password) using blowfish
<?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