From dad1c0fbb370294dacba878b19edf68d43fc3976 Mon Sep 17 00:00:00 2001 From: overtrue Date: Wed, 12 Oct 2016 12:11:40 +0800 Subject: [PATCH] :hankey: Imporve AES_KEY validation. --- src/Encryption/Encryptor.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Encryption/Encryptor.php b/src/Encryption/Encryptor.php index fa6c2b724..d8da47224 100644 --- a/src/Encryption/Encryptor.php +++ b/src/Encryption/Encryptor.php @@ -210,10 +210,14 @@ public function decode($decrypted) */ protected function getAESKey() { - if (empty($this->AESKey) || strlen($this->AESKey) !== 43) { + if (empty($this->AESKey)) { throw new InvalidConfigException("Configuration mission, 'aes_key' is required."); } + if (strlen($this->AESKey) !== 43) { + throw new InvalidConfigException("The length of 'aes_key' must be 43."); + } + return base64_decode($this->AESKey.'=', true); }