Args: _email (str): Email address to be masked Returns: str: Masked email address
(_email: str)
| 100 | |
| 101 | |
| 102 | def _mask_email(_email: str) -> str: |
| 103 | """ |
| 104 | |
| 105 | Args: |
| 106 | _email (str): Email address to be masked |
| 107 | |
| 108 | Returns: |
| 109 | str: Masked email address |
| 110 | """ |
| 111 | import re |
| 112 | email_split = re.split('@', _email) |
| 113 | username, domain = email_split |
| 114 | domain_front, *domain_back_list = re.split('[.]', domain) |
| 115 | users = re.split('[.]', username) |
| 116 | |
| 117 | def _mask_except_first_char(_str: str) -> str: |
| 118 | """ |
| 119 | Mask all characters except first character of the input string. |
| 120 | Args: |
| 121 | _str (str): Input string to be masked |
| 122 | |
| 123 | Returns: |
| 124 | str: Masked string |
| 125 | """ |
| 126 | return _str[0] + '*' * (len(_str) - 1) |
| 127 | |
| 128 | return '.'.join([_mask_except_first_char(user) for user in users]) + \ |
| 129 | '@' + _mask_except_first_char(domain_front) + '.' + \ |
| 130 | '.'.join(domain_back_list) |
| 131 | |
| 132 | |
| 133 | def send_email_code() -> Response: |
no test coverage detected