/lib/PasswordLib/Password/Implementation/MD5.php
http://github.com/ircmaxell/PHP-PasswordLib · PHP · 54 lines · 15 code · 7 blank · 32 comment · 1 complexity · d514d886be1227a2d4c0b5390da12768 MD5 · raw file
- <?php
- /**
- * The Blowfish password hashing implementation
- *
- * Use this class to generate and validate Blowfish password hashes.
- *
- * PHP version 5.3
- *
- * @category PHPPasswordLib
- * @package Password
- * @subpackage Implementation
- * @author Anthony Ferrara <ircmaxell@ircmaxell.com>
- * @copyright 2011 The Authors
- * @license http://www.opensource.org/licenses/mit-license.html MIT License
- * @version Build @@version@@
- */
- namespace PasswordLib\Password\Implementation;
- use PasswordLib\Random\Factory as RandomFactory;
- /**
- * The Blowfish password hashing implementation
- *
- * Use this class to generate and validate Blowfish password hashes.
- *
- * @category PHPPasswordLib
- * @package Password
- * @subpackage Implementation
- * @author Anthony Ferrara <ircmaxell@ircmaxell.com>
- */
- class MD5 extends Crypt {
- protected static $prefix = '$1$';
- protected $saltLen = 12;
- /**
- * Determine if the hash was made with this method
- *
- * @param string $hash The hashed data to check
- *
- * @return boolean Was the hash created by this method
- */
- public static function detect($hash) {
- static $regex = '/^\$1\$[a-zA-Z0-9.\/]{8}\$[a-zA-Z0-9.\/]{22}/';
- return 1 == preg_match($regex, $hash);
- }
- protected function generateSalt() {
- $salt = parent::generateSalt();
- return '$1$' . $salt;
- }
- }