static function __static()
 {
     $self = new XPClass(__CLASS__);
     foreach (hash_algos() as $algo) {
         MessageDigest::register($algo, $self);
     }
     // Overwrite crc32b implementation if a buggy implementation is detected.
     // Workaround for http://bugs.php.net/bug.php?id=45028
     if ('0a1cb779' === hash('crc32b', 'AAAAAAAA')) {
         MessageDigest::register('crc32b', ClassLoader::defineClass(__CLASS__ . '·CRC32bDigestImpl', $self->getName(), array(), '{
       public function doFinal() {
         $n= hexdec(hash_final($this->handle));
         return sprintf("%08x", (($n & 0xFF) << 24) + (($n & 0xFF00) << 8) + (($n & 0xFF0000) >> 8) + (($n >> 24) & 0xFF));
       }
     }'));
     }
 }
 public function unsupportedAlgorithm()
 {
     MessageDigest::newInstance('unsupported');
 }
 static function __static()
 {
     MessageDigest::register('crc16', new \lang\XPClass(__CLASS__));
 }
 /**
  * Returns message digest
  *
  * @return  security.checksum.MessageDigestImpl
  */
 public static function digest()
 {
     return MessageDigest::newInstance('sha1');
 }
Exemple #5
0
 /**
  * Salts a given string with the given salt, injects an additional site-specific
  * salt for maximum security.
  */
 private function salt($str, $uniqueSalt)
 {
     return $uniqueSalt . $str . MessageDigest::siteSalt();
 }