Skip to content

Instantly share code, notes, and snippets.

@chrismaddalena
Created April 15, 2019 13:57
Show Gist options
  • Save chrismaddalena/b8ec02ee573633e136ba78cd6eb3957c to your computer and use it in GitHub Desktop.
Save chrismaddalena/b8ec02ee573633e136ba78cd6eb3957c to your computer and use it in GitHub Desktop.
def sanitize(string):
"""Sanitize the provided string by replacing chunks with asterisks."""
sanitized_string = string
length = len(string)
if length == 32:
sanitized_string = string[0:4] + "*"*(length-8) + string[length-5:length-1]
elif length > 2:
sanitized_string = string[0] + "*"*(length-2) + string[length-1]
return sanitized_string
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment