Skip to content

Latest commit

 

History

History

hide-password-from-jdbc-url

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

We have to create a function that receives a connection string with password included and you have to mask the password i.e. change password by asterisks.

Preconditions:

  • non empty valid url
  • password always next to string section password=
  • assume password will not contain ampersand sign for sake of simplicity
  • to make it more real it has non ASCII characters
  • "password=" and "user" will occur only once

empty passwords are not validated but best solutions take empty passwords into account

Example:

Input:  jdbc:mysql://sdasdasdasd:szdasdasd:dfsdfsdfsdf/sdfsdfsdf?user=root&password=12345
Output: jdbc:mysql://sdasdasdasd:szdasdasd:dfsdfsdfsdf/sdfsdfsdf?user=root&password=*****