Does R have a function that allows a user to provide a password securely, such as Python's getpass
module?
(see http://docs.python.org/library/getpass.html for an example of what I mean)
Does R have a function that allows a user to provide a password securely, such as Python's getpass
module?
(see http://docs.python.org/library/getpass.html for an example of what I mean)
Here is a login pop-up, based on ?modalDialog.
My package keyringr solves this problem by retrieving passwords from the underlying operating system keyring (DPAPI on Windows, Keychain on OSX and the Gnome Keyring on Linux).
The vignette gives a detailed explanation on how to use the package, but if you were using OSX and have the password saved in Keychain, you could use the following command to return the password to R (where mydb_myuser is the Keychain item name):
Per m-dz in the comments above, there is a now a package for doing this called getPass, which has a single function,
getPass()
. This is a replacement forbase::readline()
.The problem is that R does not have functions to control the terminal it is running in (something like
Rncurses
); probably this is due to portability issues.Some time ago I was struggling with the same problem and I ended up with a function using TclTk:
Of course it won't work in non-GUI environments.
Very simple linux concept for terminal secure password question: