This turned out to be interesting puzzle. Seemingly so simple thing made me think a lot.
Problem statement:
You’re given a string, which is a connection string to MongoDB. It consists of parts. The parts are delimited by various characters:
- between username and password, there is ‘:’
- after password comes ‘@’
- after the ‘@’ comes host name
We want to mask any password characters with ‘*’ character.
Write an algorithm (function) that takes in a string, and writes out a masked string.
Leave a Reply