Skip to content

Commit c8993c9

Browse files
committed
Test encrypter using base64 encoded key
1 parent a4aa274 commit c8993c9

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

tests/Unit/EncrypterTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,19 @@ public function test_value_encrypted_with_old_key_can_be_decrypted()
2727
$this->assertEquals('test', $decrypted);
2828
}
2929

30+
public function test_value_encrypted_with_old_base64_key_can_be_decrypted()
31+
{
32+
$key = Str::random(32);
33+
$this->app['config']->set('identities.old_key', 'base64:'.base64_encode($key));
34+
$encrypter = new Encrypter($key, 'AES-256-CBC');
35+
36+
$encryptedWithOldKey = $encrypter->encrypt('test');
37+
38+
$decrypted = IdentityCrypt::decrypt($encryptedWithOldKey);
39+
40+
$this->assertEquals('test', $decrypted);
41+
}
42+
3043
public function test_value_can_be_encrypted()
3144
{
3245
$encrypted = IdentityCrypt::encrypt('test');

0 commit comments

Comments
 (0)