コード例 #1
0
 /**
  * @requires extension libsodium
  */
 public function testSodiumMessageSigning()
 {
     $Adam = SodiumLibrary::genSignKeypair();
     $Eve = SodiumLibrary::genSignKeypair();
     $signedMessage = SodiumLibrary::signMessage($Adam['pri'], 'message');
     $this->assertEquals('message', SodiumLibrary::verifySignature($Adam['pub'], $signedMessage));
 }
コード例 #2
0
 /**
  * @requires                 extension libsodium
  * @expectedException        scrothers\laravelsodium\Exceptions\DecryptionException
  * @expectedExceptionMessage The key provided cannot decrypt the message
  */
 public function testSodiumEncryptionFail()
 {
     $encrypted = SodiumLibrary::encrypt('foo', str_repeat('a', 16));
     SodiumLibrary::decrypt($encrypted, str_repeat('b', 16));
 }
コード例 #3
0
 /**
  * Check the given plain value against a hash.
  *
  * @param string $value
  * @param string $hashedValue
  * @param array  $unusedOptions Options are not used for Sodium password verification
  *
  * @return bool
  */
 public function check($value, $hashedValue, array $unusedOptions = [])
 {
     return SodiumLibrary::checkPassword($value, $hashedValue);
 }
コード例 #4
0
 /**
  * Decrypt the given value.
  *
  * @param string $payload
  *
  * @return string
  */
 public function decrypt($payload)
 {
     return SodiumLibrary::decrypt($payload, $this->key);
 }