Skip to content

Instantly share code, notes, and snippets.

@Javlopez
Created November 9, 2011 17:38
Show Gist options
  • Save Javlopez/1352205 to your computer and use it in GitHub Desktop.
Save Javlopez/1352205 to your computer and use it in GitHub Desktop.
A1 hack
<?php
//Added for prevent changes in a1_cores
/**
* User AUTHENTICATION module for Kohana PHP Framework using bcrypt
*
* bcrypt is highly recommended by many to safely store passwords. For more
* information, see http://codahale.com/how-to-safely-store-a-password/
*
* Based on Kohana's AUTH, Fred Wu's AUTHLITE and Woody Gilk's Bonafide
*
* @copyright (c) 2011 Wouter
* @copyright (c) 2011 Woody Gilk
* @copyright (c) 2011 Fred Wu
* @copyright (c) 2011 Kohana Team
* @license MIT
*/
class A1 extends A1_Core {
// Allowed salt characters
const SALT = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
/**
* Return a static instance of A1.
*
* @return object
*/
public static function instance($_name = 'a1')
{
static $_instances;
if ( ! isset($_instances[$_name]))
{
$_config = Kohana::$config->load($_name);
$_driver = isset($_config['driver']) ? $_config['driver'] : 'ORM';
$_class = 'A1_' . ucfirst($_driver);
$_instances[$_name] = new $_class($_name, $_config);
}
return $_instances[$_name];
}
/**
* Generates bcrypt hash for input
*
* @param string value to hash
* @param string salt (optional, will be generated if missing)
* @param int cost (optional, will be read from config if missing)
* @return string hashed input value
*/
public function hash($input, $salt = NULL, $cost = NULL)
{
return sha1($input);
}
/**
* Checks if password matches hash
*
* @param string password
* @param string hashed password
* @return boolean password matches hashed password
*/
public function check($password, $hash)
{
return ($this->hash($password) === $hash);
}
protected function _load_user($username){}
} // End A1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment