Example #1
0
 /**
  * Construct extended DES password hasher.
  * @param int $iterations Number of iterations used by algorithm.
  */
 public function __construct($iterations = 751)
 {
     assume($iterations > 0 and $iterations <= 15752960);
     $bytes = array($iterations & 0x3f, $iterations >> 6 & 0x3f, $iterations >> 12 & 0x3f, $iterations >> 18 & 0x3f);
     $base64Chars = './0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
     $iterations = '';
     foreach ($bytes as $byte) {
         $iterations .= $base64Chars[$byte];
     }
     $this->prefix = '_' . $iterations;
     parent::__construct();
 }
Example #2
0
 /**
  * Construct Blowfish password hasher.
  * @param int $cost A number between 4 and 31 that sets the cost of the hash
  * computation. 
  */
 public function __construct($cost = 10)
 {
     assume($cost >= 4 and $cost <= 31);
     $this->prefix = sprintf('$2a$%02d$', $cost);
     parent::__construct();
 }
Example #3
0
 /**
  * Construct SHA-256 password hasher.
  * @param int $rounds Number of rounds for SHA-512 algorithm.
  */
 public function __construct($rounds = 5000)
 {
     assume($rounds >= 1000 and $rounds <= 999999999);
     $this->prefix = '$5$rounds=' . $rounds . '$';
     parent::__construct();
 }