+#include "securec.h"
+
+#ifndef WIFI_MAC_LEN
+#define WIFI_MAC_LEN 6
+#endif
+
+namespace OHOS {
+namespace Wifi {
+/**
+ * @Description MAC address anonymization
+ *
+ * eg: a2:7c:b0:98:e3:92 -> a2:7c:**:**:**:92
+ *
+ * @param str - Input MAC address
+ * @return std::string - Processed MAC
+ */
+std::string MacAnonymize(const std::string str);
+
+/**
+ * @Description MAC address anonymization
+ *
+ *
eg: 192.168.0.1 -> 192.***.*.1
+ *
+ * @param str - Input MAC address
+ * @return std::string - Processed MAC
+ */
+std::string IpAnonymize(const std::string str);
+
+/**
+ * @Description Converting string MAC to a C-style MAC address
+ *
+ * @param strMac - Input MAC address
+ * @param mac - conversion result
+ * @return errno_t - EOK for success, failure for other values.
+ */
+errno_t MacStrToArray(const std::string& strMac, unsigned char mac[WIFI_MAC_LEN]);
+
+/**
+ * @Description Converting C-style MAC to a string MAC
+ *
+ * @param mac - Input MAC address
+ * @return string - conversion result.
+ */
+std::string MacArrayToStr(const unsigned char mac[WIFI_MAC_LEN]);
+
+/**
+ * @Description Check whether the array of MAC address is empty
+ *
+ * @param mac - Input MAC address
+ * @return bool - true: empty, false: not empty
+ */
+bool IsMacArrayEmpty(const unsigned char mac[WIFI_MAC_LEN]);
+
+/**
+ * @Description Converting a string IP Address to an integer IP address
+ *
+ * @param strIp - Input string IP address
+ * @return int - integer IP address
+ */
+int Ip2Number(const std::string& strIp);
+
+/**
+ * @Description Converting an integer IP address to a string IP Address
+ *
+ * @param intIp - Input integer IP address
+ * @return string - string IP address
+ */
+std::string Number2Ip(int intIp);
+} // namespace Wifi
+} // namespace OHOS
+#endif
\ No newline at end of file
diff --git a/utils/src/BUILD.gn b/utils/src/BUILD.gn
new file mode 100755
index 0000000000000000000000000000000000000000..fa472cc53198ad313990c6ff1e4aa2ebad74eb2a
--- /dev/null
+++ b/utils/src/BUILD.gn
@@ -0,0 +1,38 @@
+# Copyright (C) 2021 Huawei Device Co., Ltd.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import("//build/ohos.gni")
+
+ohos_shared_library("wifi_utils") {
+ install_enable = true
+ include_dirs = [
+ "//foundation/communication/wifi/utils/inc",
+ "//utils/native/base/include",
+ ]
+
+ sources = [ "wifi_common_util.cpp" ]
+ deps = [ "//utils/native/base:utils" ]
+
+ cflags_cc = [
+ "-std=c++17",
+ "-fno-rtti",
+ ]
+
+ ldflags = [
+ "-fPIC",
+ "-Wl,-E",
+ ]
+
+ part_name = "wifi_standard"
+ subsystem_name = "communication"
+}
diff --git a/utils/src/wifi_common_util.cpp b/utils/src/wifi_common_util.cpp
new file mode 100755
index 0000000000000000000000000000000000000000..6177f72137bfef428e5a88f095658b5c8c79c231
--- /dev/null
+++ b/utils/src/wifi_common_util.cpp
@@ -0,0 +1,168 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "wifi_common_util.h"
+#include
+
+namespace OHOS {
+namespace Wifi {
+static std::string DataAnonymize(const std::string str, const char delim,
+ const char hiddenCh, const int startIdx = 0)
+{
+ std::string s = str;
+ constexpr auto minDelimSize = 2;
+ constexpr auto minKeepSize = 6;
+ if (std::count(s.begin(), s.end(), delim) < minDelimSize) {
+ if (s.size() <= minKeepSize) {
+ return std::string(s.size(), hiddenCh);
+ }
+ auto idx1 = 2;
+ const auto idx2 = s.size() - 4;
+ while (idx1++ < idx2) {
+ s[idx1] = hiddenCh;
+ }
+ return s;
+ }
+
+ std::string::size_type begin = s.find_first_of(delim);
+ std::string::size_type end = s.find_last_of(delim);
+ int idx = 0;
+ while (idx++ < startIdx && begin < end) {
+ begin = s.find_first_of(delim, begin + 1);
+ }
+ while (begin++ != end) {
+ if (s[begin] != delim) {
+ s[begin] = hiddenCh;
+ }
+ }
+ return s;
+}
+
+std::string MacAnonymize(const std::string str)
+{
+ return DataAnonymize(str, ':', '*', 1);
+}
+
+std::string IpAnonymize(const std::string str)
+{
+ return DataAnonymize(str, '.', '*');
+}
+
+static unsigned char ConvertStrChar(char ch)
+{
+ constexpr int numDiffForHexAlphabet = 10;
+ if (ch >= '0' && ch <= '9') {
+ return (ch - '0');
+ }
+ if (ch >= 'A' && ch <= 'F') {
+ return (ch - 'A' + numDiffForHexAlphabet);
+ }
+ if (ch >= 'a' && ch <= 'f') {
+ return (ch - 'a' + numDiffForHexAlphabet);
+ }
+ return 0;
+}
+
+errno_t MacStrToArray(const std::string& strMac, unsigned char mac[WIFI_MAC_LEN])
+{
+ constexpr int strMacLen = 18;
+ char tempArray[strMacLen] = { 0 };
+ errno_t ret = memcpy_s(tempArray, strMacLen, strMac.c_str(), strMac.size() + 1);
+ if (ret != EOK) {
+ return ret;
+ }
+
+ int idx = 0;
+ constexpr int bitWidth = 4;
+ char *ptr = nullptr;
+ char *p = strtok_s(tempArray, ":", &ptr);
+ while (p != nullptr) {
+ mac[idx++] = (ConvertStrChar(*p) << bitWidth) | ConvertStrChar(*(p + 1));
+ p = strtok_s(nullptr, ":", &ptr);
+ }
+ return EOK;
+}
+
+static char ConvertArrayChar(unsigned char ch)
+{
+ constexpr int maxDecNum = 9;
+ constexpr int numDiffForHexAlphabet = 10;
+ if (ch >= 0 && ch <= maxDecNum) {
+ return '0' + ch;
+ }
+ if (ch >= 0xa && ch <= 0xf) {
+ return ch + 'a' - numDiffForHexAlphabet;
+ }
+ return '0';
+}
+
+std::string MacArrayToStr(const unsigned char mac[WIFI_MAC_LEN])
+{
+ constexpr int bitWidth = 4;
+ constexpr int noColonBit = 5;
+ std::stringstream ss;
+ for (int i = 0; i != WIFI_MAC_LEN; ++i) {
+ ss << ConvertArrayChar(mac[i] >> bitWidth) << ConvertArrayChar(mac[i] & 0xf);
+ if (i != noColonBit) {
+ ss << ":";
+ }
+ }
+ return ss.str();
+}
+
+bool IsMacArrayEmpty(const unsigned char mac[WIFI_MAC_LEN])
+{
+ for (int i = 0; i != WIFI_MAC_LEN; ++i) {
+ if (mac[i] != 0) {
+ return false;
+ }
+ }
+ return true;
+}
+
+int Ip2Number(const std::string& strIp)
+{
+ std::string::size_type front = 0;
+ std::string::size_type back = 0;
+ int number = 0;
+ int size = 32;
+ constexpr int sectionSize = 8;
+
+ std::string ip(strIp + '.');
+ while ((back = ip.find_first_of('.', back)) != (std::string::size_type)std::string::npos) {
+ number |= atoi(ip.substr(front, back - front).c_str()) << (size -= sectionSize);
+ front = ++back;
+ }
+ return number;
+}
+
+std::string Number2Ip(int intIp)
+{
+ constexpr int fourthPartMoveLen = 24;
+ constexpr int thirdPartMoveLen = 16;
+ constexpr int secondPartMoveLen = 8;
+
+ std::string ip;
+ ip.append(std::to_string(((unsigned int)intIp & 0xff000000) >> fourthPartMoveLen));
+ ip.push_back('.');
+ ip.append(std::to_string((intIp & 0x00ff0000) >> thirdPartMoveLen));
+ ip.push_back('.');
+ ip.append(std::to_string((intIp & 0x0000ff00) >> secondPartMoveLen));
+ ip.push_back('.');
+ ip.append(std::to_string(intIp & 0x000000ff));
+ return ip;
+}
+} // namespace Wifi
+} // namespace OHOS
\ No newline at end of file