Created
August 19, 2009 12:22
-
-
Save tobiastom/170334 to your computer and use it in GitHub Desktop.
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 | |
| 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