论坛备份,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
源文件
|