找回密码
 加入
搜索
查看: 656|回复: 2

[转贴] 论坛备份,RSA调用DLL加密的例子

[复制链接]
发表于 2022-5-29 23:20:50 | 显示全部楼层 |阅读模式
论坛备份,RSA调用DLL加密的例子。
#RequireAdmin
#AutoIt3Wrapper_UseX64=N
#include <Array.au3>
Dim $sStringPlain = "这是一个测试消息", $sStringEncoded = ""
Dim $hRSA_Dll = DllOpen("rsa.dll")
Dim $aRet = DllCall($hRSA_Dll, "ULONG", "RSA_generate_keys", "str", "test.privkey", "str", "test.pubkey", "ULONG*", "2048", "ULONG*", "2048")
Dim $sPrivateKey = $aRet[1]
Dim $sPublicKey = $aRet[2]
ConsoleWrite($sPrivateKey & @CRLF & @CRLF & @CRLF)
ConsoleWrite($sPublicKey & @CRLF & @CRLF & @CRLF)
Dim $tagStruct = "struct;str source; ulong source_size;str result;ulong result_size;str pubkey_content;ulong pubkey_content_size;endstruct"
Dim $tStruct = DllStructCreate($tagStruct)
DllStructSetData($tStruct, "source", $sStringPlain)
DllStructSetData($tStruct, "pubkey_content", $sPublicKey)
$aRet = DllCall($hRSA_Dll, "ULONG", "RSA_encrypt", _
"str", DllStructGetPtr($tStruct,"source"), "ULONG", StringLen(DllStructGetData($tStruct,"source")), _
"str", DllStructGetPtr($tStruct,"result"), "ULONG", 1000, _
"str", DllStructGetPtr($tStruct,"pubkey_content"), "ULONG", StringLen(DllStructGetData($tStruct,"pubkey_content")))
ConsoleWrite("@error = " & @error &@CRLF)
_ArrayDisplay($aRet)
$sStringEncoded = DllStructGetData($tStruct, "result")
ConsoleWrite(">" & $sStringEncoded & "< " &@CRLF)
所需DLL

源文件

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×

评分

参与人数 1金钱 +99 贡献 +2 收起 理由
haijie1223 + 99 + 2 赞一个!

查看全部评分

发表于 2022-5-30 09:53:30 | 显示全部楼层
lp老师,存货多多
发表于 2022-6-2 15:45:47 | 显示全部楼层
风中尘埃竟累积成伤害
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-4-27 09:14 , Processed in 0.079616 second(s), 25 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表