diff --git a/core/attributedef/AttributeEncryptedString.php b/core/attributedef/AttributeEncryptedString.php new file mode 100644 index 0000000000..30b07ce95a --- /dev/null +++ b/core/attributedef/AttributeEncryptedString.php @@ -0,0 +1,84 @@ +GetEncryptionLibrary()); + $sValue = $oSimpleCrypt->Decrypt(MetaModel::GetConfig()->GetEncryptionKey(), $aCols[$sPrefix]); + + return $sValue; + } + + /** + * Encrypt the value before storing it in the database + * + * @param $value + * + * @return array + * @throws \Exception + */ + public function GetSQLValues($value) + { + $oSimpleCrypt = new SimpleCrypt(MetaModel::GetConfig()->GetEncryptionLibrary()); + $encryptedValue = $oSimpleCrypt->Encrypt(MetaModel::GetConfig()->GetEncryptionKey(), $value); + + $aValues = array(); + $aValues[$this->Get("sql")] = $encryptedValue; + + return $aValues; + } + + protected function GetChangeRecordAdditionalData(CMDBChangeOp $oMyChangeOp, DBObject $oObject, $original, $value): void + { + if (is_null($original)) { + $original = ''; + } + $oMyChangeOp->Set("prevstring", $original); + } + + protected function GetChangeRecordClassName(): string + { + return CMDBChangeOpSetAttributeEncrypted::class; + } + + +} \ No newline at end of file