The Masker Library is a simple Python-based library designed to mask characters in a given word. It provides flexibility to mask characters from the start, end, or middle of the word while keeping a specified number of characters unmasked.
- Mask characters from the start: Mask all characters except for a specified number at the end.
- Mask characters from the end: Mask all characters except for a specified number at the start.
- Mask characters from the middle: Mask characters in the middle while keeping specified numbers of characters at both the start and the end.
You can install the Masker library using pip:
pip install masker
from masker import Masker
Create an instance of the Masker
class with an optional mask character (default is '*').
masker = Masker(mask_char='#')
Mask all characters except the specified number of characters at the end.
masked_word = masker.start("exampleword", keep_char=4)
print(masked_word) # Output: "######word"
Mask all characters except the specified number of characters at the start.
masked_word = masker.end("exampleword", keep_char=3)
print(masked_word) # Output: "exa########"
Mask characters in the middle while keeping specified numbers of characters at both the start and the end.
masked_word = masker.mid("exampleword", start_keep_char=2, end_keep_char=3)
print(masked_word) # Output: "ex#######ord"
Returns the word with the specified number of characters masked from the start.
- Parameters:
word
(str): The input word to be masked.keep_char
(int): Number of characters to keep unmasked from the start.
- Returns: (str) The masked word.
Returns the word with the specified number of characters masked from the end.
- Parameters:
word
(str): The input word to be masked.keep_char
(int): Number of characters to keep unmasked from the end.
- Returns: (str) The masked word.
Returns the word with the specified number of characters masked from the start and end.
- Parameters:
word
(str): The input word to be masked.start_keep_char
(int): Number of characters to keep unmasked from the start.end_keep_char
(int): Number of characters to keep unmasked from the end.
- Returns: (str) The masked word.
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please submit a pull request or open an issue to discuss changes.
Happy masking!