Created
January 20, 2022 02:47
-
-
Save mttaggart/aa67c96b61ebc1a9ba4cbfd655931492 to your computer and use it in GitHub Desktop.
Nim GetPass
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# With thanks to reilly! | |
proc getPass(prompt = "Secret: "): string = | |
stdout.write(prompt) | |
while result == "" or result[^1] notin ['\x0D', '\n']: | |
result.add getch() | |
stdout.write("*") | |
stdout.write("\n") | |
return result.strip() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Awesome, this is exactly what I was looking for! Thanks!
May I recommend adding the necessary imports to the code for it to compile: