/** * @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)); }
/** * @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)); }
/** * 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); }
/** * Decrypt the given value. * * @param string $payload * * @return string */ public function decrypt($payload) { return SodiumLibrary::decrypt($payload, $this->key); }