1 /* 2 * Copyright (c) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef OHOS_DISTRIBUTED_DATA_NATIVE_GDB_GDB_UTILS_H 17 #define OHOS_DISTRIBUTED_DATA_NATIVE_GDB_GDB_UTILS_H 18 #include <string> 19 20 #include "rdb_visibility.h" 21 22 namespace OHOS::DistributedDataAip { 23 class API_EXPORT GdbUtils { 24 public: 25 static bool IsTransactionGql(const std::string &gql); 26 static int CreateDirectory(const std::string &databaseDir); 27 static std::string Anonymous(const std::string &srcFile); 28 static void ClearAndZeroString(std::string &str); 29 static std::string GetConfigStr(const std::vector<uint8_t> &keys, bool isEncrypt); 30 static const char *GetEncryptKey(const std::vector<uint8_t> &encryptedKey, char outBuff[], size_t outBufSize); 31 private: 32 static constexpr int DIR_RWXRWS__X = 0771; 33 static constexpr const char *GRD_OPEN_CONFIG_STR = 34 R"("pageSize": 4, "crcCheckEnable": 0, "defaultIsolationLevel": 3, "redoFlushByTrx": 1, "metaInfoBak": 1)"; 35 static std::string GetAnonymousName(const std::string& fileName); 36 static std::string AnonyDigits(const std::string& fileName); 37 }; 38 } 39 40 #endif