mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-12-23 21:43:17 +00:00
30 lines
668 B
PHP
30 lines
668 B
PHP
<?php
|
|
|
|
namespace Tests\Unit;
|
|
|
|
use phpseclib\Crypt\RSA;
|
|
use Tests\TestCase;
|
|
|
|
class CryptoTest extends TestCase
|
|
{
|
|
/**
|
|
* A basic test to check if PHPSecLib is installed.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function testLibraryInstalled()
|
|
{
|
|
$this->assertTrue(class_exists('\phpseclib\Crypt\RSA'));
|
|
}
|
|
|
|
public function testRSASigning()
|
|
{
|
|
$rsa = new RSA();
|
|
extract($rsa->createKey());
|
|
$rsa->loadKey($privatekey);
|
|
$plaintext = 'pixelfed rsa test';
|
|
$signature = $rsa->sign($plaintext);
|
|
$rsa->loadKey($publickey);
|
|
$this->assertTrue($rsa->verify($plaintext, $signature));
|
|
}
|
|
}
|