mirror of https://github.com/pixelfed/pixelfed
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
660 B
PHTML
30 lines
660 B
PHTML
7 years ago
|
<?php
|
||
|
|
||
|
namespace Tests\Unit;
|
||
|
|
||
|
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 \phpseclib\Crypt\RSA();
|
||
|
extract($rsa->createKey());
|
||
|
$rsa->loadKey($privatekey);
|
||
|
$plaintext = 'pixelfed rsa test';
|
||
|
$signature = $rsa->sign($plaintext);
|
||
|
$rsa->loadKey($publickey);
|
||
|
$this->assertTrue($rsa->verify($plaintext, $signature));
|
||
|
}
|
||
|
}
|