Skip to content

Instantly share code, notes, and snippets.

@mttaggart
Created January 20, 2022 02:47
Show Gist options
  • Save mttaggart/aa67c96b61ebc1a9ba4cbfd655931492 to your computer and use it in GitHub Desktop.
Save mttaggart/aa67c96b61ebc1a9ba4cbfd655931492 to your computer and use it in GitHub Desktop.
Nim GetPass
# 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()
@SaeedBaig
Copy link

Awesome, this is exactly what I was looking for! Thanks!

May I recommend adding the necessary imports to the code for it to compile:

from terminal import getch
from strutils import strip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment