-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Minor cleanup (phpcs, phpmd etc) Now testing on multiple php versions
- Loading branch information
Showing
5 changed files
with
38 additions
and
32 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ coverage | |
vendor | ||
.DS_Store | ||
.idea | ||
composer.lock |
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,7 +1,10 @@ | ||
language: php | ||
|
||
php: | ||
- 5.6 | ||
- 7.0 | ||
- 7.1 | ||
- 7.2 | ||
|
||
before_script: | ||
- composer self-update | ||
|
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 |
---|---|---|
|
@@ -2,20 +2,20 @@ | |
/** | ||
* Encrypt/decrypt data to a format compatible with MySQL aes_encrypt() & aes_decrypt() functions. | ||
* | ||
* @package NoProtocol\Encryption\MySQL\AES | ||
* @author Bob Fanger <[email protected]> | ||
* @author Anne Jan Brouwer <[email protected]> | ||
* @author Govert Verschuur <[email protected]> | ||
* @author Renan Martins Pimentel <[email protected]> | ||
* @copyright 2016 NoProtocol | ||
* @license https://opensource.org/licenses/MIT The MIT License (MIT) | ||
* @version 2.0.0 | ||
* @link http://www.smashingmagazine.com/2012/05/replicating-mysql-aes-encryption-methods-with-php/ | ||
* @package NoProtocol\Encryption\MySQL\AES | ||
* @author Bob Fanger <[email protected]> | ||
* @author Anne Jan Brouwer <[email protected]> | ||
* @author Govert Verschuur <[email protected]> | ||
* @author Renan Martins Pimentel <[email protected]> | ||
* @copyright 2016 NoProtocol | ||
* @license https://opensource.org/licenses/MIT The MIT License (MIT) | ||
* @version 2.0.0 | ||
* @link http://www.smashingmagazine.com/2012/05/replicating-mysql-aes-encryption-methods-with-php/ | ||
*/ | ||
|
||
namespace NoProtocol\Encryption\MySQL\AES; | ||
|
||
class Crypter | ||
class Crypter | ||
{ | ||
protected $key; | ||
|
||
|
@@ -27,17 +27,17 @@ function __construct($seed) | |
/** | ||
* Encrypts the data | ||
* | ||
* @since 2.0 | ||
* @since 2.0 | ||
* @param string $data A string of data to encrypt. | ||
* @return (binary) string The encrypted data | ||
*/ | ||
public function encrypt($data) | ||
{ | ||
$chiperIvLength = openssl_cipher_iv_length('AES-128-ECB'); | ||
$iv = openssl_random_pseudo_bytes($chiperIvLength); | ||
$pad_value = 16 - (strlen($data) % 16); | ||
$padValue = 16 - (strlen($data) % 16); | ||
return openssl_encrypt( | ||
str_pad($data, (16 * (floor(strlen($data) / 16) + 1)), chr($pad_value)), | ||
str_pad($data, (16 * (floor(strlen($data) / 16) + 1)), chr($padValue)), | ||
'AES-128-ECB', | ||
$this->key, | ||
OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING, | ||
|
@@ -48,7 +48,7 @@ public function encrypt($data) | |
/** | ||
* Decrypts the data. | ||
* | ||
* @since 2.0 | ||
* @since 2.0 | ||
* @param string $data A (binary) string of encrypted data | ||
* @return string Decrypted data | ||
*/ | ||
|
@@ -61,13 +61,13 @@ public function decrypt($data) | |
OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING | ||
); | ||
|
||
return rtrim($data,"\x00..\x10"); | ||
return rtrim($data, "\x00..\x10"); | ||
} | ||
|
||
/** | ||
* Create and set the key used for encryption. | ||
* | ||
* @since 2.0 | ||
* @since 2.0 | ||
* @param string $seed The seed used to create the key. | ||
* @return (binary) string the key to use in the encryption process. | ||
*/ | ||
|
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