Title: | Masked User Input |
---|---|
Description: | A micro-package for reading "passwords", i.e. reading user input with masking, so that the input is not displayed as it is typed. Currently we have support for 'RStudio', the command line (every OS), and any platform where 'tcltk' is present. |
Authors: | Drew Schmidt [aut, cre], Wei-Chen Chen [aut], Gabor Csardi [ctb] (Improved terminal detection), Rich FitzJohn [ctb] |
Maintainer: | Drew Schmidt <[email protected]> |
License: | BSD 2-clause License + file LICENSE |
Version: | 0.2-4 |
Built: | 2024-11-04 02:47:33 UTC |
Source: | https://github.com/wrathematics/getpass |
A micro-package for reading "passwords", i.e. reading
user input with masking. The package's only exported function,
getPass()
, behaves similarly to R's own readline()
, only
the user text is not printed as it is typed. Currently we have support
for RStudio, the command line (every OS), and any platform where tcltk
is present.
Drew Schmidt and Wei-Chen Chen
Project URL: https://github.com/wrathematics/getPass
Password reader. Like R's readline()
but the user-typed input
text is not printed to the screen.
getPass(msg = "PASSWORD: ", noblank = FALSE, forcemask = FALSE)
getPass(msg = "PASSWORD: ", noblank = FALSE, forcemask = FALSE)
msg |
The message to enter into the R session before prompting
for the masked input. This can be any single string,
possibly including a "blank" ( |
noblank |
Logical; should blank passwords ( |
forcemask |
Logical; should the function stop with an error if masking
is not supported? If |
Masking (i.e., not displaying the literal typed text as input) is supported on most, but not all platforms. It is supported in RStudio, provided you have a suitable version of the GUI. It should also work in the terminal on any major OS. Finally, it will work in any environment where the tcltk package is available (e.g., Windows with RGui). Notably, this will not work with Emacs; passwords can be read, but there will be no masking.
In the terminal, the maximum length for input is 255 characters. Additionally, messages printed to the terminal (including the "*" masking) are printed to stderr.
If input is provided, then that is returned. If the user cancels
(e.g., cancel button on RStudio or ctrl+c in the terminal), then
NULL
is returned.
## Not run: # Basic usage getPass::getPass() # Get password with a custom message getPass::getPass("Enter the password: ") ## End(Not run)
## Not run: # Basic usage getPass::getPass() # Get password with a custom message getPass::getPass("Enter the password: ") ## End(Not run)