Learn R Programming

keyringr (version 0.4.0)

decrypt_dpapi_pw: Decrypt passwords encrypted with the Microsoft Data Protection API

Description

Decrypt passwords encrypted with the Microsoft Data Protection API

Usage

decrypt_dpapi_pw(file)

Arguments

file
File that holds a password encrypted using DPAPI

Value

An 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

Requires Powershell to be installed and execution policy set to RemoteSigned. This can be achieved by running Set-ExecutionPolicy RemoteSigned from Powershell.

Examples

Run this code
## Not run: ------------------------------------
# # First run the command below from Powershell:
# # Read-Host "PW?" -AsSecureString |  ConvertFrom-SecureString | Out-File "C:\Temp\Password.txt"
# # Now execute the following R commands to decrypt the password and save it in
# # variable "x".  Note that if run without assignment, the password will not
# # be displayed in the console.  Passwords must be saved to a variable or used
# # inline within a connection string.
# library("keyringr")
# x <- decrypt_dpapi_pw("C:\\Temp\\Password.txt")
# 
# # function is best used in a connection string command:
# ch <- odbcConnect("some dsn", uid = "user1", pwd = decrypt_dpapi_pw("C:\\Temp\\Password.txt"))
## ---------------------------------------------

Run the code above in your browser using DataLab