Learn R Programming

keyringr (version 0.4.0)

decrypt_kc_pw: Get a generic password from macOS Keychain using the 'security' cli

Description

Get a generic password from macOS Keychain using the 'security' cli

Usage

decrypt_kc_pw(label, type = "generic")

Arguments

label
Keychain password label
type
Leychain password type. Either "generic" or "internet".

Value

Returns a decrypted password as an invisible string. Invisible means that the password won't be displayed in the console, but can be assigned to a variable or used inline.

Details

Passwords must be saved in Keychain prior to using the function. macOS may require the user to grant access to "security" the first time the function is run for each password. It is important to select "Always allow", which will prevent similar dialogs in the future.

Examples

Run this code
## Not run: ------------------------------------
# # First store a password in Keychain
# # now return the password above to the R environment
# x <- decrypt_kc_pw("label")
# 
# # function is best used in a connection string command:
# ch <- odbcConnect("some dsn", uid = "user1", pwd = decrypt_kc_pw("mydb_myuser"))
## ---------------------------------------------

Run the code above in your browser using DataLab