CryptoTest.php 660 B

1234567891011121314151617181920212223242526272829
  1. <?php
  2. namespace Tests\Unit;
  3. use Tests\TestCase;
  4. class CryptoTest extends TestCase
  5. {
  6. /**
  7. * A basic test to check if PHPSecLib is installed.
  8. *
  9. * @return void
  10. */
  11. public function testLibraryInstalled()
  12. {
  13. $this->assertTrue(class_exists('\phpseclib\Crypt\RSA'));
  14. }
  15. public function testRSASigning()
  16. {
  17. $rsa = new \phpseclib\Crypt\RSA();
  18. extract($rsa->createKey());
  19. $rsa->loadKey($privatekey);
  20. $plaintext = 'pixelfed rsa test';
  21. $signature = $rsa->sign($plaintext);
  22. $rsa->loadKey($publickey);
  23. $this->assertTrue($rsa->verify($plaintext, $signature));
  24. }
  25. }