Skip to content

Commit

Permalink
Merge pull request #7 from peter279k/fix_key
Browse files Browse the repository at this point in the history
Fix key is same on different Encryption classes
  • Loading branch information
lablnet authored Feb 23, 2020
2 parents 9bc7740 + e2245a1 commit 43b514b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Encryption.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ class Encryption
*/
public function __construct($key, $adapter = null)
{
($adapter !== null) ? $this->setAdapter($adapter) : $this->setAdapter('openssl');
$this->setKey($key);
($adapter !== null) ? $this->setAdapter($adapter) : $this->setAdapter('openssl');
}

/**
Expand Down
11 changes: 11 additions & 0 deletions tests/EncryptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@

class EncryptionTest extends TestCase
{
public function testEncryptAndDecryptOnDifferentKeyWithOpenSsl()
{
$encryption = new Encryption('12345678990-=====-===', 'openssl');
$encryptedString = $encryption->encrypt('plain-text');

$encryption2 = new Encryption('different_key', 'openssl');
$decryptedString = $encryption2->decrypt($encryptedString);

$this->assertFalse($decryptedString);
}

public function testEncryptAndDecryptWithOpenSsl()
{
$encryption = new Encryption('12345678990-=====-===', 'openssl');
Expand Down

0 comments on commit 43b514b

Please sign in to comment.