-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e0864e7
commit e02e834
Showing
8 changed files
with
15 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,5 @@ | ||
<?php | ||
|
||
/** | ||
* @package encryptor | ||
* @link https://github.com/bayfrontmedia/encryptor | ||
* @author John Robinson <[email protected]> | ||
* @copyright 2020 Bayfront Media | ||
*/ | ||
|
||
namespace Bayfront\Encryptor; | ||
|
||
use Exception; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,5 @@ | ||
<?php | ||
|
||
/** | ||
* @package encryptor | ||
* @link https://github.com/bayfrontmedia/encryptor | ||
* @author John Robinson <[email protected]> | ||
* @copyright 2020 Bayfront Media | ||
*/ | ||
|
||
namespace Bayfront\Encryptor; | ||
|
||
use Exception; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,12 @@ | ||
<?php | ||
|
||
/** | ||
* @package encryptor | ||
* @link https://github.com/bayfrontmedia/encryptor | ||
* @author John Robinson <[email protected]> | ||
* @copyright 2020 Bayfront Media | ||
*/ | ||
|
||
namespace Bayfront\Encryptor; | ||
|
||
class Encryptor | ||
{ | ||
|
||
protected $key; | ||
protected $cipher; | ||
protected string $key; | ||
protected string $cipher; | ||
|
||
/** | ||
* Encrypt constructor. | ||
|
@@ -48,12 +41,12 @@ public function __construct(string $key, string $cipher = 'AES-256-CBC') | |
* @throws EncryptException | ||
*/ | ||
|
||
protected function _createIv() | ||
protected function _createIv(): string | ||
{ | ||
|
||
$iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length($this->cipher)); | ||
|
||
if (false === $iv) { | ||
if (!$iv) { | ||
throw new EncryptException('Unable to create Initialization Vector'); | ||
} | ||
|
||
|
@@ -91,7 +84,7 @@ public function getCipher(): string | |
* @return string | ||
*/ | ||
|
||
protected function _createHash(string $iv, $value): string | ||
protected function _createHash(string $iv, mixed $value): string | ||
{ | ||
return hash_hmac('sha256', $iv . $value, $this->key); | ||
} | ||
|
@@ -107,7 +100,7 @@ protected function _createHash(string $iv, $value): string | |
* @throws EncryptException | ||
*/ | ||
|
||
public function encrypt($value, bool $serialize = true): string | ||
public function encrypt(mixed $value, bool $serialize = true): string | ||
{ | ||
|
||
if (true === $serialize) { | ||
|
@@ -174,7 +167,7 @@ public function encryptString(string $value): string | |
* @throws DecryptException | ||
*/ | ||
|
||
public function decrypt(string $data, bool $unserialize = true) | ||
public function decrypt(string $data, bool $unserialize = true): mixed | ||
{ | ||
|
||
$data = json_decode(base64_decode($data), true); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,5 @@ | ||
<?php | ||
|
||
/** | ||
* @package encryptor | ||
* @link https://github.com/bayfrontmedia/encryptor | ||
* @author John Robinson <[email protected]> | ||
* @copyright 2020 Bayfront Media | ||
*/ | ||
|
||
namespace Bayfront\Encryptor; | ||
|
||
use Exception; | ||
|
This file was deleted.
Oops, something went wrong.