hashAndEncrypt() public static method

1. Hash password using bcrypt-base64-SHA256 2. Encrypt-then-MAC the hash
public static hashAndEncrypt ( string $password, Defuse\Crypto\Key $aesKey ) : string
$password string
$aesKey Defuse\Crypto\Key
return string
コード例 #1
0
 /**
  * @expectedException \Defuse\Crypto\Exception\WrongKeyOrModifiedCiphertextException
  */
 public function testBitflip()
 {
     $key = Key::createNewRandomKey();
     $password = PasswordLock::hashAndEncrypt('YELLOW SUBMARINE', $key);
     $password[0] = \ord($password[0]) === 0 ? 255 : 0;
     PasswordLock::decryptAndVerify('YELLOW SUBMARINE', $password, $key);
 }
コード例 #2
0
 /**
  * @expectedException \Defuse\Crypto\Exception\InvalidCiphertext
  */
 public function testBitflip()
 {
     $key = \Defuse\Crypto\Key::LoadFromAsciiSafeString(\hex2bin('0102030405060708090a0b0c0d0e0f10'));
     $password = PasswordLock::hashAndEncrypt('YELLOW SUBMARINE', $key);
     $password[0] = \ord($password[0]) === 0 ? 255 : 0;
     PasswordLock::decryptAndVerify('YELLOW SUBMARINE', $password, $key);
 }
コード例 #3
0
 /**
  * @expectedException \Defuse\Crypto\Exception\InvalidCiphertext
  */
 public function testBitflip()
 {
     $key = \hex2bin('0102030405060708090a0b0c0d0e0f10');
     $password = PasswordLock::hashAndEncrypt('YELLOW SUBMARINE', $key);
     $password[0] = \ord($password[0]) === 0 ? 255 : 0;
     PasswordLock::decryptAndVerify('YELLOW SUBMARINE', $password, $key);
 }
コード例 #4
0
ファイル: Password.php プロジェクト: narrowspark/framework
 /**
  * {@inheritdoc}
  */
 public function create(string $password) : string
 {
     return PasswordLock::hashAndEncrypt($password, $this->key);
 }