Compare commits

...

4 Commits
2.7.1 ... 2.7.2

Author SHA1 Message Date
Yuri Kuznetsov
bdeaaa7965 version 2014-12-01 11:00:37 +02:00
Yuri Kuznetsov
2768a975d7 fix crypt 2014-12-01 10:42:56 +02:00
Yuri Kuznetsov
2533854745 Merge branch 'hotfix/2.7.1' into stable 2014-11-28 10:50:56 +02:00
Yuri Kuznetsov
14d83c3a19 Merge branch 'master' into stable 2014-11-12 16:58:35 +02:00
2 changed files with 18 additions and 3 deletions

View File

@@ -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()

View File

@@ -1,6 +1,6 @@
{
"name": "espocrm",
"version": "2.7.1",
"version": "2.7.2",
"description": "",
"main": "index.php",
"repository": "",