Defuse\Crypto\Crypto::encryptWithPassword PHP Метод

encryptWithPassword() публичный статический Метод

Encrypts a string with a password, using a slow key derivation function to make password cracking more expensive.
public static encryptWithPassword ( string $plaintext, string $password, boolean $raw_binary = false ) : string
$plaintext string
$password string
$raw_binary boolean
Результат string
    public static function encryptWithPassword($plaintext, $password, $raw_binary = false)
    {
        return self::encryptInternal($plaintext, KeyOrPassword::createFromPassword($password), $raw_binary);
    }

Usage Example

Пример #1
0
 /**
  * @param $username
  * @param $passwordHash
  * @return string
  */
 public static function generateToken($username, $passwordHash)
 {
     $data = time() - 1 . '|' . $username;
     $token = Crypto::encryptWithPassword($data, $passwordHash);
     return $token;
 }
All Usage Examples Of Defuse\Crypto\Crypto::encryptWithPassword