Fix: encrypt key don't exist in install mode

This commit is contained in:
Regis Houssin
2009-09-16 08:31:33 +00:00
parent c19df2514d
commit 11b92539d6

View File

@@ -688,17 +688,17 @@ class DoliDb
*/
function encrypt($fieldorvalue, $cryptType=0, $cryptKey='', $withQuotes=0)
{
$return = $fieldorvalue;
$return = ($withQuotes?"'":"").addslashes($fieldorvalue).($withQuotes?"'":"");
if ($cryptType && !empty($cryptKey))
{
if ($cryptType == 2)
{
$return = 'AES_ENCRYPT('.($withQuotes?"'":"").addslashes($fieldorvalue).($withQuotes?"'":"").',\''.$cryptKey.'\')';
$return = 'AES_ENCRYPT('.$return.',\''.$cryptKey.'\')';
}
else if ($cryptType == 1)
{
$return = 'DES_ENCRYPT('.($withQuotes?"'":"").addslashes($fieldorvalue).($withQuotes?"'":"").',\''.$cryptKey.'\')';
$return = 'DES_ENCRYPT('.$return.',\''.$cryptKey.'\')';
}
}