无法从 WinApi crate 调用 CryptDecrypt,因为它找不到模块

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

documentation 中它说该函数在 winapi::um::wincrypt::CryptDecrypt 中但是当我安装 crate 并将其放入我的项目时一切正常,直到我尝试调用我得到的函数以下错误消息:

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`

我的目标是从 Chrome 存储密码的计算机上的 "Local Data" 文件中解密密码。我在 Rust 中使用名为 winapi 的 Windows win32crypt API 绑定。我正在尝试完成类似于 chromepass 但在 Rust 中的事情。

来自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.

在这种情况下,您需要添加wincrypt:

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

版本 0.2.8 太旧,所以当我将 wincrypt 作为功能添加到 Cargo.toml 时,出现构建错误。

features = ["wincrypt"] 在版本 0.3.9 中工作 better/differently。