/** * @requires extension libsodium * @expectedException Layerworx\Phpsodium\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)); }
/** * @requires extension libsodium */ public function testSlowHashing() { $value = SodiumLibrary::hashPassword('password', true); $this->assertNotSame('password', $value); $this->assertTrue(SodiumLibrary::checkPassword('password', $value)); }
/** * @requires extension libsodium */ public function testSodiumMessageSigning() { $Adam = SodiumLibrary::genSignKeypair(); $signedMessage = SodiumLibrary::signMessage($Adam['pri'], 'message'); $this->assertEquals('message', SodiumLibrary::verifySignature($Adam['pub'], $signedMessage)); }