mirror of
https://github.com/espocrm/espocrm.git
synced 2026-03-05 00:07:00 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bdeaaa7965 | ||
|
|
2768a975d7 | ||
|
|
2533854745 | ||
|
|
14d83c3a19 |
@@ -29,6 +29,8 @@ class Crypt
|
||||
private $key = null;
|
||||
|
||||
private $cryptKey = null;
|
||||
|
||||
private $iv = null;
|
||||
|
||||
public function __construct($config)
|
||||
{
|
||||
@@ -43,15 +45,28 @@ class Crypt
|
||||
}
|
||||
return $this->key;
|
||||
}
|
||||
|
||||
protected function getIv()
|
||||
{
|
||||
if (empty($this->iv)) {
|
||||
$this->iv = mcrypt_create_iv(16, MCRYPT_RAND);
|
||||
}
|
||||
return $this->iv;
|
||||
}
|
||||
|
||||
public function encrypt($string)
|
||||
{
|
||||
return base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $this->getKey(), $string, MCRYPT_MODE_CBC));
|
||||
$iv = $this->getIv();
|
||||
return base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $this->getKey(), $string, MCRYPT_MODE_CBC, $iv) . $iv);
|
||||
}
|
||||
|
||||
public function decrypt($encryptedString)
|
||||
{
|
||||
return trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $this->getKey(), base64_decode($encryptedString), MCRYPT_MODE_CBC));
|
||||
$encryptedString = base64_decode($encryptedString);
|
||||
|
||||
$string = substr($encryptedString, 0, strlen($encryptedString) - 16);
|
||||
$iv = substr($encryptedString, -16);
|
||||
return trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $this->getKey(), $string, MCRYPT_MODE_CBC, $iv));
|
||||
}
|
||||
|
||||
public function generateKey()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "espocrm",
|
||||
"version": "2.7.1",
|
||||
"version": "2.7.2",
|
||||
"description": "",
|
||||
"main": "index.php",
|
||||
"repository": "",
|
||||
|
||||
Reference in New Issue
Block a user