Exemple #1
0
        $vr ^= $this->pbox[16];
        $vl ^= $this->pbox[17];
        return array($vl, $vr);
    }
    /**
     * Encryption Round
     *
     * @param int $integer
     * @return int
     */
    function sbox_round($integer)
    {
        //Split $integer into four 8 Bit blocks
        $b0 = $integer << 24 & 0xff;
        $b1 = $integer << 16 & 0xff;
        $b2 = $integer << 8 & 0xff;
        $b3 = $integer & 0xff;
        $return = $this->sbox0[$b0] + $this->sbox1[$b1] % 4294967295;
        $return = ($return ^ $this->sbox2[$b2]) + $this->sbox3[$b3] % 4294967295;
        return $return;
    }
}
echo "TOTO</br>";
$blowfish = new blowfish();
$key = 'This is key';
$blowfish->keys($key);
$plaintext = 'This is plain text';
$cipher = $blowfish->encrypt($plaintext);
#$text = $blowfish->blowfish_decrypt($cipher); //$text == 'This is plain text'
echo $cipher . "</br>";
#echo $text."</br>";
Exemple #2
0
 /**
  * Create initialization vector.
  *
  * This vector is considered to be recreatable the very same way resulting
  * in the same vector, though hardly depending on current user's session to
  * be less predictable by attackers gathering access on ciphers.
  *
  * @return string initialization vector to use
  */
 protected static function getIV()
 {
     return blowfish::get($_SERVER['REMOTE_ADDR'] . $_COOKIE['_txf'] . $_SERVER['HTTP_USER_AGENT'], $_SERVER['HTTP_HOST']) . blowfish::get($_SERVER['HTTP_HOST'] . $_COOKIE['_txf'] . $_SERVER['HTTP_USER_AGENT'], $_SERVER['REMOTE_ADDR']);
 }
Exemple #3
0
 /**
  * Retrieves hash on an object descriptor and its related secret information
  * to be valid at date of timestamp.
  *
  * @param string $object some public object hash is to be used for (e.g. a user's name)
  * @param string $secret some internal-only information related to that object (e.g. the user's internal ID or similar)
  * @param int $timestamp timestamp of day generated hash is considered valid on
  * @return string hash on object and its related secret valid for day of given timestamp
  */
 protected static function _get($object, $secret, $timestamp)
 {
     $salt = blowfish::get($object, 'cePharUm-S3cr3t-54lT' . static::_date($timestamp), true);
     $hash = substr(preg_replace('#[/+=]#', '', blowfish::get($secret, $salt)), 12, 16);
     return $hash;
 }