-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathAESCryptoServiceProviderTest.php
More file actions
27 lines (21 loc) · 809 Bytes
/
AESCryptoServiceProviderTest.php
File metadata and controls
27 lines (21 loc) · 809 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?php
namespace MayMeow\Cryptography\Tests;
use MayMeow\Cryptography\AESCryptoServiceProvider;
use PHPUnit\Framework\TestCase;
class AESCryptoServiceProviderTest extends TestCase
{
/** @test */
public function textCanBeEncryptedAndDecrypted() : void
{
$csp = new AESCryptoServiceProvider();
$csp->generateIV();
$key = $csp->generateKey();
$plainText = "This is going to be encrypted!";
$encryptedText= $csp->encrypt($plainText);
$encryptedTextLegacy = $csp->encrypt($plainText, legacy: true);
$csp2 = new AESCryptoServiceProvider();
$csp2->setKey($key);
$this->assertEquals($plainText, $csp2->decrypt($encryptedText));
$this->assertEquals($plainText, $csp2->decrypt($encryptedTextLegacy, legacy: true));
}
}