Skip to content

Instantly share code, notes, and snippets.

@isaacs
Created August 7, 2010 18:40
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save isaacs/513059 to your computer and use it in GitHub Desktop.
Save isaacs/513059 to your computer and use it in GitHub Desktop.
var stdin = process.stdin
, stdio = process.binding("stdio")
stdio.setRawMode()
// let the data flow.
// stdin is "paused" initially.
stdin.resume()
var password = ""
stdin.on("data", function (c) {
c = c + ""
switch (c) {
case "\n": case "\r": case "\u0004":
stdio.setRawMode(false)
console.log("you entered: "+password)
stdin.pause()
break
case "\u0003":
process.exit()
break
default:
password += c
break
}
})
// hello, http://geekli.st!
@csanz
Copy link

csanz commented Apr 23, 2011

awesome + clean + useful piece of code.

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