Skip to content

Commit af43afd

Browse files
authored
Merge pull request #11 from cleverage/tests/improve-mcrypt-to-sodium-tests
Add a test to tests encryption from mcrypt to sodium
2 parents 0a9aaec + 8e517c5 commit af43afd

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/Entity/CryptableInterface.php

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
* postLoad You need to return a array of the properties that needs to be encrypted and decrypted
1616
*
1717
* @author Vincent Chalnot <[email protected]>
18+
*
19+
* @deprecated This class is not necessary anymore. Use the encrypt_string and encrypt_text Doctrine type instead.
1820
*/
1921
interface CryptableInterface
2022
{

tests/PHPUnit/Doctrine/ValueEncrypterTest.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,12 @@ public function testEncryptWithMCryptEncryptedString(string $value): void
4343
{
4444
$mcrypt = $this->registry->getEncryptionManager(Rijndael256MCryptEncryptionAdapter::getCode());
4545

46-
$mcrypt->encryptString($value);
46+
$encryptedString = $mcrypt->encryptString($value);
47+
$encryptedStringWithSodium = $this->registry->getEncryptionManager(XChaChaPolySodiumEncryptionAdapter::getCode());
48+
$decryptedValue = $this->encrypter->decrypt($encryptedString);
49+
50+
$this->assertEquals($value, $decryptedValue);
51+
$this->assertNotEquals($encryptedStringWithSodium, $decryptedValue);
4752
}
4853

4954
protected function setUp(string $defaultAdapterCode = null): void

0 commit comments

Comments
 (0)