Skip to content

Instantly share code, notes, and snippets.

@tobiastom
Created August 19, 2009 12:22
Show Gist options
  • Save tobiastom/170334 to your computer and use it in GitHub Desktop.
Save tobiastom/170334 to your computer and use it in GitHub Desktop.
<?php
class securehasing {
public static function registerImplementation($alias, $class) {}
public static function instanceForImplementation($alias = 'sha512') {}
}
interface securehasing_interface {
public function random($length = 12);
public function phonemic($length = 8, $flags = null);
public function compare($password);
}
class sha512securehasing implements securehasing_interface {
protected function randomBytes($length) {}
public function random($length = 12) {}
public function phonemic($length = 8, $flags = null) {}
public function compare($password) {}
}
// default include whatever
securehasing::registerImplementation('sha512', 'sha512securehasing');
// user tobias existiert und hat eine implementierung in der datenbank hinterlegt
$hash = securehasing::instanceForImplementation($user->hashingImplementation);
$hash->compare('baz');
// user christian ist neu, nutzt also den default
$hash = securehasing::instanceForImplementation()
$hash->phonemic();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment