Decrypt Passwords from Gnome Keyring, Windows Data Protection API and macOS Keychain

Decrypts passwords stored in the Gnome Keyring, macOS Keychain and strings encrypted with the Windows Data Protection API.

keyringr is an R package that provides access to the Gnome Keyring and the Windows Data Encryption API (DPAPI). A typical use case would be to call on of the keyringr functions to supply the password for a database connection string. For example:

# Windows - call decrypt_dpapi_pw() to get password from file containing text encrypted with DPAPI
channel <- odbcConnect("test", uid="ripley", pwd=decrypt_dpapi_pw("c:\\passwords\\test.dat"))
# Linux - call decrypt_gk_pw() to get password form Gnome Keyring
channel <- odbcConnect("test", uid="ripley", pwd=decrypt_gk_pw("db test uid ripley"))

This function utilises the Windows Data Protection API. Passwords must be encrypted via PowerShell prior to using the R function. The following command encrypts a password and saves the encrypted string to C:\Temp\Password.txt:

Read-Host "Password" -AsSecureString |  ConvertFrom-SecureString | Out-File "C:\\Temp\\Password.txt"

This produces an encrypted string, which can only be decrypted by the same user and computer that encrypted the password. This means that the command above must be executed on each PC that the function will be used on.

It can be useful to store the encrypted password files in a standardised directly, such as C:\Users\username\DPAPI\computer_name\ This can be achieved with the following PowerShell script:

put script here!!!

This function utilises the Gnome Keyring and secret-tool. Passwords must be initially stored in the Keyring using a command in the following format:

put script here!!


Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.


0.4.0 by Josh Gilfillan, a year ago

Browse source code at

Authors: Josh Gilfillan

Documentation:   PDF Manual  

MIT + file LICENSE license

Imports stringr

Suggests knitr, rmarkdown

See at CRAN