In Python, the pywin32
library provides a module named win32crypt
which has a method called CryptUnpotectData
to decrypt Windows encrypted data by using the Windows API.
This is how I have applied it in Python:
import win32crypt
# ...
password = win32crypt.CryptUnprotectData(EncrytedPassword, None, None, None, 0)
I have found a binding for the winapi
but I can't find the CryptUnprotectData
function, the closest I found to an equivalent is the CryptDecrypt
function.
Here is my implementation of it in Rust:
extern crate winapi;
let decrypted_password = winapi::um::wincrypt::CryptDecrypt(/* ???? */);
I am not sure how to make use of this function and if it will decrypt my encrypted password string and return it. I would love if more experienced Rust users could shed some light on this for me using an example or explanation.
If you go to the documentation for winapi (linked from the crate page as well as the README), you will find a large search box:
If you type "CryptUnprotectData" into that search box, you will receive 3 results:
Clicking on the first result will lead you to the specific function, CryptUnprotectData
. As described in Cannot call CryptDecrypt from the WinApi crate because it could not find the module, you need to use the appropriate feature flag to enable the function (dpapi
).
As the README states:
Why is there no documentation on how to use anything?
This crate is nothing more than raw bindings to Windows API. If you wish to know how to use the various functionality in Windows API, you can look up the various items on MSDN which is full of detailed documentation.
Usage of this function is described on MSDN.