Cannot call CryptDecrypt from the WinApi crate because it could not find the module

六月ゝ 毕业季﹏ 提交于 2019-12-11 02:53:05

问题


In the documentation it says that the function is in winapi::um::wincrypt::CryptDecrypt but when I install the crate and bring it in my project everything works fine until I try to call the function where I get the following error message:

error[E0433]: failed to resolve. Could not find `wincrypt` in `um`
  --> src\main.rs:68:39
   |
68 |  let decrypted_password = winapi::um::wincrypt::CryptDecrypt(password);
   |                                       ^^^^^^^^ Could not find `wincrypt` in `um`

My goal is to decrypt passwords from the "Local Data" file on my computer where Chrome stores passwords. I am using the Windows win32crypt API binding called winapi in Rust. I am trying to accomplish something similar to chromepass but in Rust.


回答1:


From the crate-level documentation:

Frequently asked questions

Why am I getting errors about unresolved imports?

Each module is gated on a feature flag, so you must enable the appropriate feature to gain access to those items. For example, if you want to use something from winapi::um::winuser you must enable the winuser feature.

In this case, you need to add wincrypt:

[target.'cfg(windows)'.dependencies]
winapi = { version = "0.3", features = ["wincrypt"] }


来源:https://stackoverflow.com/questions/48508952/cannot-call-cryptdecrypt-from-the-winapi-crate-because-it-could-not-find-the-mod

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!