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

标签 windows api winapi rust rust-cargo

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 存储密码的“本地数据”文件中解密密码。我在 Rust 中使用名为 winapi 的 Windows win32crypt API 绑定(bind)。我正在尝试完成类似于 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"] }

关于windows - 无法从 WinApi crate 调用 CryptDecrypt,因为它找不到模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48508952/

相关文章:

windows - 如何在批处理中检查文件是否为空

c++ - 新线程只发出第一条指令并且永远不会恢复

c++ - 我应该为 DirectX 11 使用什么 SDK?

c# - Windows 服务与简单程序

javascript - Angular 5 中的 422(无法处理的实体)错误

javascript - 一键提交两份表单并发布到两个不同的 API

jquery - 如何通过 jQuery 获取 GitHub 存储库上最新提交的 SHA?

c++ - 使用 Visual Studio 将 HTML 浏览器嵌入到 native C++/Win32 项目中

c++ - 如何从 C++(winapi) 中的资源加载 GDI::Image (GIF)?

windows - 自签名 SSL 证书适用于 IE 和 curl,但不适用于现代浏览器