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