How can I mask input from the command line? Basic use case: I want to enter a password when prompted, and I need to either see *'s or nothing at all.
[:] creates an empty Map. The colon is there to distinguish it from [] , which creates an empty List. This groovy code: def foo = [:]
Password masking is the act of hiding passwords as bullets or asterisks when the user enters the password. Password masking is an attempt to protect the user against shoulder surfers who look at the screen.
A multiline comment starts with /* and can be found at any position in the line. The characters following /* will be considered part of the comment, including new line characters, up to the first */ closing the comment. Multiline comments can thus be put at the end of a statement, or even inside a statement.
Since you can call Java libraries from Groovy, you may find your answer in the question How to mask a password in Java 5?.
In short, use Console.readPassword()
(Java 6 or later).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With