Leaderboard
Popular Content
Showing content with the highest reputation on 08/16/2022 in all areas
-
Curl UDF - libcurl with x64 support
Stormgrade reacted to Beege for a topic
Here is a rewrite of Wards Curl UDF with the binary portion removed so that it can support external (updated) library's and add support for x64. I added quite a few new header constants and also have included the curl-ca-bundle certificate. I modified the first two "easy" examples to demonstrate using the ca-bundle to verify the SSL peer. I also added a new example showing how to download the certificate chain. The 7.82.0 version dlls are included but they can be replaced with updated versions as they come out in the future. You can find future releases here : https://curl.se/windows/ Let me know if you have any issues. Cheers! 🙂 Curlx64.7z1 point -
CryptoNG UDF - Cryptography API: Next Generation
Stormgrade reacted to TheXman for a file
Version v2.2.0
1,418 downloads
Encryption / Decryption / Hashing / Signing Purpose Cryptography API: Next Generation (CNG) is Microsoft's long-term replacement for their CryptoAPI. Microsoft's CNG is designed to be extensible at many levels and cryptography agnostic in behavior. Although the Crypt.au3 UDF lib that is installed with AutoIt3 still works well, the advapi32.dll functions that it uses have been deprecated. In addition the Crypt.au3 UDF lib, as it is currently written, has a very limited ability to decrypt AES data that was not encrypted using Crypt.au3 functions. That is because Crypt.au3 functions do not allow you to specify an actual key or initialization vector (IV). It only lets you specify data to be used to derive a key and uses a static IV. This UDF was created to offer a replacement for the deprecated functions used by Crypt.au3. According to Microsoft, deprecated functions may be removed in future release. It was also created to allow more flexibility and functionality in encryption/decryption/hashing/signing and to expand the ability for users to implement cryptography in their scripts. Description This UDF implements some of Microsoft's Cryptography API: Next Generation (CNG) Win32 API functions. It implements functions to encrypt/decrypt text and files, generate hashes, derive keys using Password-Based Key Derivation Function 2 (PBKDF2), create and verify signatures, and has several cryptography-related helper functions. The UDF can implement any encryption/decryption algorithms and hashing algorithms that are supported by the installed cryptography providers on the PC in which it is running. Most, if not all, of the "magic number" values that you would commonly use to specify that desired algorithms, key bit lengths, and other magic number type values, are already defined as constants or enums in the UDF file. To flatten the learning curve, there is an example file that shows examples of all of the major functionality. This example file is not created to be an exhaustive set of how to implement each feature and parameter. It is designed to give you a template or guide to help you hit the ground running in terms of using the functions. I have tried to fully document the headers of all of the functions as well as the code within the functions themselves. As of v1.4.0, there is also a Help file that includes all of the functions, with examples. Current UDF Functions Algorithm-Specific Symmetric Encryption/Decryption Functions _CryptoNG_AES_CBC_EncryptData _CryptoNG_AES_CBC_DecryptData _CryptoNG_AES_CBC_EncryptFile _CryptoNG_AES_CBC_DecryptFile _CryptoNG_AES_ECB_EncryptData _CryptoNG_AES_ECB_DecryptData _CryptoNG_AES_GCM_EncryptData _CryptoNG_AES_GCM_DecryptData _CryptoNG_3DES_CBC_EncryptData _CryptoNG_3DES_CBC_DecryptData _CryptoNG_3DES_CBC_EncryptFile _CryptoNG_3DES_CBC_DecryptFile Generic Symmetric Encryption/Decryption Functions _CryptoNG_EncryptData _CryptoNG_DecryptData _CryptoNG_EncryptFile _CryptoNG_DecryptFile Hashing Functions _CryptoNG_HashData _CryptoNG_HashFile _CryptoNG_PBKDF2 Asymmetric (Public/Private Key) Cryptography Functions _CryptoNG_ECDSA_CreateKeyPair _CryptoNG_ECDSA_SignHash _CryptoNG_ECDSA_VerifySignature _CryptoNG_RSA_CreateKeyPair _CryptoNG_RSA_EncryptData _CryptoNG_RSA_DecryptData _CryptoNG_RSA_SignHash _CryptoNG_RSA_VerifySignature Misc / Helper Functions _CryptoNG_CryptBinaryToString _CryptoNG_CryptStringToBinary _CryptoNG_GenerateRandom _CryptoNG_EnumAlgorithms _CryptoNG_EnumRegisteredProviders _CryptoNG_EnumKeyStorageProviders _CryptoNG_LastErrorMessage _CryptoNG_Version Related Links Cryptography API: Next Generation - Main Page Cryptography API: Next Generation - Reference Cryptography API: Next Generation - Primitives Cryptography API: Next Generation - Cryptographic Algorithm Providers1 point -
Your initial example, when sent to the POSTMAN Echo API, sends the form data correctly. Are you sure you are posting the correct script and error message? If so, then the problem is probably the format of the POST data. It would help if you provided more information about the API. The site doesn't have API examples? You could also try URL encoding your POST data before sending it. The second $sPostData in my example has the string URL encoded. Both ways produce the same result when sent to the POSTMAN Echo API. However, your API server may want the URL encoded string when special characters exist. If so, there are several URL encoding & decoding functions posted to the forum. Just do a search for URLEncode. Example: #include <Constants.au3> #include <MyIncludes\json\json.au3> http_post_example() Func http_post_example() Local $oComErr = Null ;~ Local $sPostData = 'username=myrealusername&password=]=oN9>fh2!O' Local $sPostData = 'username=myrealusername&password=%5D=oN9%3Efh2!O' ;URL Encoded ;Register COM Error Handler $oComErr = ObjEvent("AutoIt.Error", com_error_handler) If @error Then Exit MsgBox($MB_ICONERROR + $MB_TOPMOST, "ERROR", _ "Unable to register COM error handler - @error = " & @error) ;Send POST request using WINHTTP COM object With ObjCreate("winhttp.winhttprequest.5.1") ;Open POST request, set request header(s), and send the request .Open("POST", "https://postman-echo.com/post") If @error Then Exit MsgBox($MB_ICONERROR + $MB_TOPMOST, "ERROR", _ StringFormat("(0x%X) %s", $oComErr.RetCode, $oComErr.WinDescription)) .SetRequestHeader("Content-Type" , "application/x-www-form-urlencoded") .SetRequestHeader("Accept" , "application/json") .SetRequestHeader("Cache-Control", "no-cache") .Send($sPostData) If @error Then Exit MsgBox($MB_ICONERROR + $MB_TOPMOST, "ERROR", _ StringFormat("(0x%X) %s", $oComErr.RetCode, $oComErr.Description)) ConsoleWrite(StringFormat("HTTP Status: %s (%s)", .Status, .StatusText) & @CRLF) ;If http status code not 200, exit with message If .Status <> 200 Then Exit MsgBox($MB_ICONERROR + $MB_TOPMOST, "ERROR", _ StringFormat("HTTP Status Code = %s %s", .Status, .StatusText)) ;Display formatted JSON response ConsoleWrite(@CRLF & "HTTP Response:" & @CRLF) ConsoleWrite(Json_Encode(Json_Decode(.ResponseText), $JSON_PRETTY_PRINT + $JSON_UNESCAPED_SLASHES) & @CRLF) EndWith EndFunc Func com_error_handler($oError) With $oError ConsoleWrite(@ScriptName & " (" & .scriptline & ") : ==> COM Error intercepted !" & @CRLF) ConsoleWrite(@TAB & "Error Number........... " & "0x" & Hex(.number) & @CRLF) ConsoleWrite(@TAB & "Error WinDescription... " & StringStripWS(.windescription, $STR_STRIPTRAILING) & @CRLF) ConsoleWrite(@TAB & "Error Description...... " & StringStripWS(.description , $STR_STRIPTRAILING) & @CRLF) ConsoleWrite(@TAB & "Error ScriptLine....... " & .scriptline & @CRLF) ConsoleWrite(@TAB & "Error RetCode.......... " & "0x" & Hex(.retcode) & @CRLF) EndWith Return ; Return so @error can be trapped by the calling function EndFunc Output: HTTP Status: 200 (OK) HTTP Response: { "args": {}, "data": "", "files": {}, "form": { "username": "myrealusername", "password": "]=oN9>fh2!O" }, "headers": { "x-forwarded-proto": "https", "x-forwarded-port": "443", "host": "postman-echo.com", "x-amzn-trace-id": "Root=1-62fc3310-05b42b003c0bbd127b09c301", "content-length": "44", "cache-control": "no-cache", "content-type": "application/x-www-form-urlencoded; Charset=UTF-8", "accept": "application/json", "user-agent": "Mozilla/4.0 (compatible; Win32; WinHttp.WinHttpRequest.5)" }, "json": { "username": "myrealusername", "password": "]=oN9>fh2!O" }, "url": "https://postman-echo.com/post" }1 point
-
Take a look at https://www.autoitscript.com/autoit3/docs/functions/ControlSetText.htm Edit : You can add the € sign behind the numeric string ( ... & " €"). This will be ignored by the Number function (but don't put it before the value !). Which position is suitable for this operation, however, I can not judge, because I only see your code snippet.1 point
-
Here is little optimized version: 1) In StringReplace use CaseSense=1 -> faster 2) StringReplace+StringStripWS do only if neccessary (just before Beep) -> less CPU load in main loop $sTextOld = '' While True If WinActive("[Title:Caja]") Then ;Check if POS Window is currently active. $sText = ControlGetText("Caja", "", "ThunderRT6TextBox21") ;Get data from "TOTAL Textbox" If $sText <> $sTextOld Then ;Beep if "TOTAL Textbox" value changes If Number(StringReplace(StringStripWS($sText, 8), ',', '.',1)) <> 0 Then Beep(660, 300) ;Beep sound (not when 0 / 0,00) $sTextOld = $sText EndIf EndIf Sleep(0) WEnd1 point
-
To use DllCall() correctly, be aware of the following: The AutoIt DllCall() function can only be used to execute functions in dll-files implemented in unmanaged languages such as C, C++ and Pascal. The DllCall() function cannot be used to execute functions in .NET assembly dll-files implemented in managed languages such as C#, F# or VB.NET. Note that this isn't an AutoIt limitation or a limitation in the DllCall() function. It's a very general limitation when trying to mix any unmanaged programming language with managed code. AutoIt is an unmanaged programming language. Fortunately, there are methods to integrate unmanaged and managed code. This also applies to AutoIt and C# code. With an AutoIt background, the DotNetAll.au3 UDF as implemented in Using C# and VB.NET Code is by far the easiest way to execute C# (or VB.NET) code directly within an AutoIt script. With this technique you have eg. no need for a C# (or VB.NET) IDE, but can handle all code in SciTE. See bottom of this post for a complete list of the benefits of the technique. But this method works best if the C# (or VB.NET) code only depends on internal .NET assembly dll-files or relatively simple external .NET assembly dll-files. In your case it seems to be a slightly more advanced external .NET assembly dll-file. To be sure to get the code working in AutoIt, use the technique briefly demonstrated in this post. This method requires an IDE to compile the C# code into a .NET assembly dll-file and it requires the dll-file to be registered with RegAsm.exe. Why is more C# code needed when a .NET assembly dll file already exists and contains the actual UploadZipFile() method? In your case with the UploadZipFile() method, it is necessary to add a bit more C# code to use the method in AutoIt. The problem is that UploadZipFile() is a static method, and a static method cannot be executed in AutoIt. In the C# code, you must include the .NET assembly dll file and you must write a small wrapper method that works in AutoIt. The wrapper method must be a simple public method as shown in the example in the link and the method must of course call the static UploadZipFile() method. Depending on your experience with AutoIt objects and C# code, getting the code to work isn't necessarily a completely trivial task.1 point
-
First post on the forums Thanks so much for this! Made my day a lot easier! I'm using the HttpGet function in a GUI and if the page is not available my GUI starts freezing up so I added in $oHTTP.SetTimeouts to help with error handling. Func HttpGet($sURL, $sData = "") Local $oHTTP = ObjCreate("WinHttp.WinHttpRequest.5.1") $oHTTP.Open("GET", $sURL & "?" & $sData, False) $oHTTP.SetTimeouts(50, 50, 50, 50) If (@error) Then Return SetError(1, 0, 0) $oHTTP.Send() If (@error) Then Return SetError(2, 0, 0) If ($oHTTP.Status <> 200) Then Return SetError(3, 0, 0) Return SetError(0, 0, $oHTTP.ResponseText) EndFunc ;==>HttpGet The values are for ResolveTimeout, ConnectTimeout, SendTimeout, ReceiveTimeout. I've set to 50ms because I'm working with a LAN connection and my requests are tiny.1 point