~aleteoryx/muditaos

muditaos/module-utils/utility/Anonymize.hpp -rw-r--r-- 947 bytes
a405cad6Aleteoryx trim readme 6 days ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/blob/master/LICENSE.md

#pragma once

#include <string>
#include <algorithm>
#include <functional>
#include <map>

namespace utils::anonymize
{
    // Determine how many characters to leave at the end of anonymized substring
    constexpr auto SIGNS_TO_LEAVE_FOR_PIN_AND_PUK       = 0;
    constexpr auto SIGNS_TO_LEAVE_FOR_PHONE_NUMBERS     = 2;
    constexpr auto SIGNS_TO_LEAVE_FOR_NET_PROVIDER_NAME = 1;

    // Basic function to anonymize provided string
    std::string anonymizeInQuotationMarks(const std::string &textToAnonymize, std::size_t singsToLeaveAtEnd = 0);
    std::string anonymizeNumbers(const std::string &textToAnonymize, std::size_t singsToLeaveAtEnd = 0);

    // To anonymize logs from cellular
    std::string anonymizeCellularIfNecessary(const std::string &text);

} // namespace utils::anonymize