Skip to main content
Don't Be STUPID
 Grasp SOLID
          Anthony Ferrara
        MidWestPHP 2013
DISCLAIMERS
None Of These
  Principles
Are Limited To OOP
These Are
Principles
 Not Laws
(Well, Some Are)
function hash_password($password = NULL, $salt = NULL, $salt2)
{
    if($password === NULL)
        return FALSE;

    if($salt === NULL)
        $salt = config_item('encryption_key');

    $password = (string) $password;
    $salt = (string) $salt;

    $ci =& get_instance();

    $ci->load->library('encrypt');

    $salt2 = $ci->encrypt->decode(base64_decode($salt2),
             config_item('encryption_key2'));

    return crypt(
        hash_hmac('whirlpool', $password,
            hash('sha512',
                crypt($salt,
                     '$6$rounds=100[000$' .
                     hash('sha256', $salt)
                ) . '$'
            )
        ),
        '$2y$12$'. $salt2 .'$'
    );
}
S
T
U
P
I
D
Singletons
T
U
P
I
D
Singletons
Tight Coupling
U
P
I
D
Singletons
Tight Coupling
Untestable Code
P
I
D
Singletons
Tight Coupling
Untestable Code
Premature Optimization
I
D
Singletons
Tight Coupling
Untestable Code
Premature Optimization
Indescriptive Naming
D
Singletons
Tight Coupling
Untestable Code
Premature Optimization
Indescriptive Naming
Duplication
The Rule
Of Three
S
O
L
I
D
Single Responsibility Principle
O
L
I
D
Single Responsibility Principle
Open Closed Principle
L
I
D
Single Responsibility Principle
Open Closed Principle
Liskov Substitution Principle
I
D
Single Responsibility Principle
Open Closed Principle
Liskov Substitution Principle
Interface Segregation Principle
D
Single Responsibility Principle
Open Closed Principle
Liskov Substitution Principle
Interface Segregation Principle
Dependency Inversion Principle
Law of
   Leaky
Abstractions
Law of
Demeter
Principle Of
 Least
Knowledge
Principle Of
  Least
Astonishment
Principle Of
 Good
Enough
Anthony Ferrara
   joind.in/8219
    @ircmaxell
blog.ircmaxell.com
me@ircmaxell.com
youtube.com/ircmaxell