Advertisement
okpalan

mask_email.py

Feb 24th, 2024
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | Source Code | 0 0
  1. import re
  2.  
  3. def mask_email(email):
  4. parts = email.split('@')
  5. username = parts[0]
  6. domain = parts[1]
  7. masked_username = username[0] + '*****' + username[-1]
  8. masked_email = masked_username + '@' + domain
  9. return masked_email
  10.  
  11. # Example usage
  12. email1 = "example.email@gmail.com"
  13. email2 = "john.doe@example.com"
  14. print(mask_email(email1)) # Output: e*****l@gmail.com
  15. print(mask_email(email2)) # Output: j*****e@example.com
  16.  
Tags: email mask
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement