Skip to content

Instantly share code, notes, and snippets.

@douglaswth
Forked from samuelkadolph/getpass.rb
Last active August 29, 2015 13:57
Show Gist options
  • Save douglaswth/9885448 to your computer and use it in GitHub Desktop.
Save douglaswth/9885448 to your computer and use it in GitHub Desktop.
require "ffi"
module GetPass
extend FFI::Library
case RbConfig::CONFIG["host_os"]
when "cygwin"
ffi_lib "win1"
else
ffi_lib "libc"
end
attach_function :getpass, [:string], :string
end
GetPass.getpass("Prompt: ") # => "secret"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment