1 /* 2 * Copyright (c) 2024-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 SIGNATRUETOOLS_BYTEARRAYTUTILS_EXCEPTION_H 17 #define SIGNATRUETOOLS_BYTEARRAYTUTILS_EXCEPTION_H 18 19 #include <string> 20 #include <algorithm> 21 22 #include "memory.h" 23 24 namespace OHOS { 25 namespace SignatureTools { 26 class ByteArrayUtils { 27 public: 28 static int InsertIntToByteArray(std::vector<int8_t>& desByte, int index, int num); 29 static int InsertShortToByteArray(std::vector<int8_t>& desByte, size_t desByteLen, int index, short num); 30 static int InsertByteToByteArray(std::vector<int8_t>& des, int start, std::vector<int8_t> src, int srcLen); 31 static int InsertCharToByteArray(std::vector<int8_t>& des, int start, std::string src); 32 33 private: 34 static constexpr int BIT_SIZE = 8; 35 static constexpr int DOUBLE_BIT_SIZE = 16; 36 static constexpr int TRIPLE_BIT_SIZE = 24; 37 static constexpr int HALF_INTEGER_BYTES = 2; 38 }; 39 } // namespace SignatureTools 40 } // namespace OHOS 41 #endif // SIGNATRUETOOLS_BYTEARRAYTUTILS_EXCEPTION_H