【问题标题】:Is there a Rust equivalent to win32crypt.CryptUnprotectData() in RustRust 中是否有与 win32crypt.CryptUnprotectData() 等效的 Rust
【发布时间】:2018-01-30 22:06:10
【问题描述】:

在 Python 中,pywin32 库提供了一个名为 win32crypt 的模块,该模块具有一个名为 CryptUnpotectData 的方法,用于使用 Windows API 解密 Windows 加密数据。

这就是我在 Python 中应用它的方式:

import win32crypt
# ...
password = win32crypt.CryptUnprotectData(EncrytedPassword, None, None, None, 0)

我找到了winapi 的绑定,但我找不到CryptUnprotectData 函数,我找到的最接近等效函数的是the CryptDecrypt function

这是我在 Rust 中的实现:

extern crate winapi;
let decrypted_password = winapi::um::wincrypt::CryptDecrypt(/* ???? */);

我不确定如何使用这个函数,以及它是否会解密我的加密密码字符串并返回它。如果更有经验的 Rust 用户可以通过示例或解释为我阐明这一点,我会很高兴。

【问题讨论】:

标签: winapi encryption rust pywin32 rust-cargo


【解决方案1】:

如果您转到documentation for winapi(链接自crate page 以及README),您会发现一个大搜索框:

如果您在该搜索框中输入“CryptUnprotectData”,您将收到 3 个结果:

单击第一个结果将引导您进入特定功能,CryptUnprotectData。如Cannot call CryptDecrypt from the WinApi crate because it could not find the module 中所述,您需要使用适当的功能标志来启用该功能(dpapi)。

正如自述文件所述:

为什么没有关于如何使用任何东西的文档?

这个 crate 只不过是对 Windows API 的原始绑定。如果你 想知道如何使用 Windows API 中的各种功能,你 可以在MSDN上查找各种项目,里面很详细 文档。

这个函数的用法是described on MSDN

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-04-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-03
    • 1970-01-01
    • 2017-12-30
    • 2019-05-10
    相关资源
    最近更新 更多