pixelfed/tests/Unit/CryptoTest.php

32 lines
756 B
PHP
Raw Normal View History

2018-08-23 04:45:25 +00:00
<?php
namespace Tests\Unit;
use Tests\TestCase;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;
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));
}
}