Leaderboard
Popular Content
Showing content with the highest reputation on 12/02/2019 in all areas
-
CryptoNG UDF - Cryptography API: Next Generation
Stormgrade and 2 others reacted to TheXman for a file
Version v2.2.0
1,424 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 Providers3 points -
Can I get hold of MsgBox button caption? - SOLVED
pixelsearch and 2 others reacted to CYCho for a topic
With the help of some friends in the Korean AutoIt community, I found a solution. #include <MsgBoxConstants.au3> #include <WinAPIRes.au3> $hInstance = _WinAPI_LoadLibrary("USER32.DLL") $text = "Click '" & _WinAPI_LoadString($hInstance, 800) & "' to continue, '" & _WinAPI_LoadString($hInstance, 801) & "' to quit" _WinAPI_FreeLibrary($hInstance) MsgBox($MB_OKCANCEL, "MUI Question", $text) #cs String ID's in User32.dll OK 800 Cancel 801 Abort 802 Retry 803 Ignore 804 Yes 805 No 806 Close 807 Help 808 TryAgain 809 #ce3 points -
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 Providers Get CryptoNG from the AutoIt Downloads Area2 points
-
CryptoNG UDF - Cryptography API: Next Gen
argumentum and one other reacted to TheXman for a topic
I usually put those directives in the script that includes the UDF. By putting them in the UDF itself, it may override directives used by the user. which I'm not sure would be an appropriate thing to do.2 points -
_ChooseColor() but better
seadoggie01 reacted to argumentum for a topic
..I'm coding the High Contrast theme editor and using the _ChooseColor() I wandered why it does not keep the the custom colors I've added. Found that adding a static declaration would do it. But why stop there. Why not keep going, So I put this together that is non code braking ( backwards compatible ), to replace the one in <Misc.au3> Hopefully will replace the default one in the next release Better use the new code down this post.1 point -
List text one character at a time - (Moved)
Musashi reacted to pixelsearch for a topic
I may be mistaken, but can _GUICtrlEdit_InsertText() be easily used when OP needs the text to be inserted at caret position ? Anyway, here is a simple example using GUICtrlSetData() , where the 3rd parameter is... Nine #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> GUICreate("Insertion at caret place", 400, 300) $idEdit = GUICtrlCreateEdit("- It was written :" & @CRLF & "< >" & @CRLF & _ "- Really ?", 2, 2, 394, 268) GUISetState(@SW_SHOW) MsgBox($MB_TOPMOST, '', 'Click the caret between "<>" in the edit control' & @CRLF & _ 'Then press Ok') $sStringToInsert = "Jackdaws love my big sphinx of quartz" For $i = 1 to StringLen($sStringToInsert) GUICtrlSetData($idEdit, StringMid($sStringToInsert, $i, 1), 9) ; 9 or anything but "" Sleep(100) Next Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete()1 point -
CryptoNG UDF - Cryptography API: Next Gen
argumentum reacted to TheXman for a topic
Yes, you are correct. The $__gbDllOpened flag is a holdover from some original logic that I removed. It really isn't necessary because I can just check whether the handle = -1 (as you have pointed out). Thanks, I will definitely clean that up. Yes, one could execute internal/helper functions if they choose to. But if they do so, hopefully they understand what they are doing. To me, although they are visible, I look at internal functions as I would functions that are private in scope in an OOP environment. They should not be executed out of context or really at all. But you are right, people will do it.1 point -
CryptoNG UDF - Cryptography API: Next Gen
TheXman reacted to argumentum for a topic
browsing the UDF I believe this sould be added/mod. Func __CryptoNG_Shutdown() _DebugOut(@CRLF & "Function: __CryptoNG_Shutdown()") ;If dll file is open, then close it If $__gbDllOpened Then DllClose($__ghBcryptDll) $__ghBcryptDll = -1 ; <======= $__gbDllOpened = False EndIf EndFunc Love it !, thanks for sharing.1 point -
Added your UDF to the wiki1 point
-
I'm not sure this is a good idea as it forces the user to code his script so it passes this checks as well.1 point
-
Thanks for sharing. Is this possible to use CNG feature to use Qualified Certificate store on CryptoCard ? For example sign PDF with PADES ?1 point
-
Update variable value automatically in terms of its definition
pixelsearch reacted to Zedna for a topic
Global $b $a = A(2) $b = $a + 1 ; now $b is 3 $a = A(5) ; now I want $b to be 6 (because $b = $a + 1) MsgBox (0, "", $b, 0) ; but no, $b is still only 3 Func A($value) $b = $value + 1 Return $value EndFunc EDIT: This is fixed version Global $b $a = A(2) ; now $b is 3 $a = A(5) ; now I want $b to be 6 (because $b = $a + 1) MsgBox (0, "", $b, 0) ; but no, $b is still only 3 Func A($value) $b = $value + 1 Return $value EndFunc1 point -
Array / Ubound question, please help.
FrancescoDiMuro reacted to pixelsearch for a topic
Hi LisHawj The 1st control you create in a GUI always got an id = 3 (LarsJ, here) If you check the value of the 1st control you created ($Button1), it will indicate 3, not 1 That difference of 2 explains why you're having 2 buttons not being re-enabled, as : UBound($aButtons) = $Button13 = 15 Edit: concerning the mysterious control id's 1 and 2 I was lucky enough to find a control returning id = 1, but id# 2 is still a mystery. Maybe one day we'll know about id# 2 too...1 point -
1 point
-
Array / Ubound question, please help.
pixelsearch reacted to jugador for a topic
#include <ScrollBarConstants.au3> #include <WindowsConstants.au3> #include <ButtonConstants.au3> #include <StaticConstants.au3> #include <AutoItConstants.au3> #include <MsgBoxConstants.au3> #include <GUIConstantsEx.au3> #include <EditConstants.au3> #include <GuiComboBox.au3> #include <GuiRichEdit.au3> #include <GuiButton.au3> #include <Constants.au3> #include <GUIEdit.au3> #include <Array.au3> #include <File.au3> Global $aButtons[15] Global $LHToolBar _Start() Func _Start() $LHToolBar = GUICreate("Toolbar", 823, 56, -1, -1) $Button15 = GUICtrlCreateButton("", 773, 6, 43, 43, $BS_ICON) For $i = 0 To UBound($aButtons,1) - 1 $aButtons[$i] = GUICtrlCreateButton("", 6 + ($i*49), 6, 43, 43, $BS_ICON) Next GUISetState(@SW_SHOW) ;Press ESC key to terminates the toolbar HotKeySet("{ESC}", "_Stop") For $i = 0 To UBound($aButtons,1) - 1 GUICtrlSetState($aButtons[$i], $GUI_DISABLE) Next MsgBox(0, "", "Buttons are DISABLED!") ;Let's enable those 15 buttons. For $i = 0 To UBound($aButtons,1) - 1 GUICtrlSetState($aButtons[$i], $GUI_ENABLE) Next While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd EndFunc ;==>_Start Func _Stop() Exit EndFunc ;==>_Stop1 point -
_ChooseColor() but better
argumentum reacted to seadoggie01 for a topic
I like it! Two (minor) nitpicks: 1. $iCustColors is really a boolean, should be used and named as such (Dyslexia is a b***h with 0's and 1's, so I never remember which is True) 2. Include a header to let us know what the possible results of the function are... I guessed a bit in generating this ; #FUNCTION# ==================================================================================================================== ; Name ..........: _ChooseColor_mod ; Description ...: ; Syntax ........: _ChooseColor_mod([$iReturnType = 0[, $iColorRef = 0[, $iRefType = 0[, $hWndOwnder = 0[, $vCustColors = Default]]]]]) ; Parameters ....: $iReturnType - [optional] an integer value. Default is 0. See remarks for values. ; $iColorRef - [optional] an integer value. Default is 0. ; $iRefType - [optional] an integer value. Default is 0. See remarks for values. ; $hWndOwnder - [optional] a handle to the parent window. Default is 0. ; $vCustColors - [optional] an array of colors to show as custom values. Default is Default. ; Return values .: Success - Hex value of the selected color ; Failure - $vCustomColors is returned if set, otherwise, -1 is returned. Also sets @error: ; | -3 - User canceled or invalid dll struct. ; | -4 - Invalid $iReturnType value. ; | Other - Error returned from Dll call. ; Author ........: argumentum ; Modified ......: ; Remarks .......: $iReturnType can be 0 (RGB COLORREF), 1 (Hex BGR), or 2 (Hex RGB). ;~ $iRefType can be 0 (ColorRef), 1 (BGR Hex), or 2 (RGB Hex). ; Related .......: ; Link ..........: https://www.autoitscript.com/forum/topic/200985-_choosecolor-but-better/ ; Example .......: ; ===============================================================================================================================1 point -
Just set hotkey "ctnl+shift+s" to send the "S" See my sample here: _HotKey("{ESC}") ; press ESC to exit _HotKey("^+S") ; press Cntl+Shift+s to send "S" to application _HotKey("+s") ; press Shift+s to send hotkey shift+s to application Func _HotKey($hotkey = "") ; ! ALT + SHIFT ^ CONTROL # WinKey Switch @HotKeyPressed Case "{ESC}" Exit 0 * MsgBox(64 + 262144, Default, "Exit", 1) Case "^+S" HotKeySet("+s") Send("S") HotKeySet("+s", "_HotKey") Case "+s" MsgBox(64+262144, Default, "Shift+s sent to application",2) Case Else If Not IsDeclared("hotkey") Then Return MsgBox(16 + 262144, Default, "No CASE statement defined for hotkey " & @HotKeyPressed, 15) If HotKeySet($hotkey, "_Hotkey") = 0 Then Return MsgBox(16 + 262144, Default, "Hotkey " & $hotkey & " invalid or set by another application.", 15) EndSwitch EndFunc ;==>_HotKey While Sleep(100) ; here should be your application. WEnd ; meanwhile, here is a dummy loop. #cs place cursor in next line before pressing F5 (run) SSSS #ce1 point
-
Try using a translator. If you have some code, post it. If you don't we will be hardly able to help you out...1 point
-
$LVN_KEYDOWN/$tagNMLVKEYDOWN does not work in 64 bit
pixelsearch reacted to LarsJ for a topic
Add this to top of _WM_NOTIFY function and it should work: Local Const $tagNMLVKEYDOWN = $tagNMHDR & ";word VKey;uint Flags"1 point -
This works for me. #include <GuiMenu.au3> #include <WindowsConstants.au3> #include <GuiConstantsEx.au3> #include <GuiListView.au3> #include <GuiImageList.au3> ; ======================================================================== ; Global variables ; ======================================================================== Global Enum $idEdit = 1000, $idDelete, $idAdd ; ======================================================================== ; Main ; ======================================================================== $hGUI = GUICreate('Context Menu Demo (Right Click)', 400, 300) $hListView = _GUICtrlListView_Create($hGUI, "", 2, 2, 394, 268) _GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES)) GUISetState() GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") ; Load images $hImage = _GUIImageList_Create() _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0xFF0000, 16, 16)) _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0x00FF00, 16, 16)) _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0x0000FF, 16, 16)) _GUICtrlListView_SetImageList($hListView, $hImage, 1) ; Add columns _GUICtrlListView_InsertColumn($hListView, 0, "Column 1", 200) ; Add items _GUICtrlListView_AddItem($hListView, "Row 1: Col 1", 0) _GUICtrlListView_AddItem($hListView, "Row 2: Col 1", 1) _GUICtrlListView_AddItem($hListView, "Row 3: Col 1", 2) GUISetState() ; Loop until user exits Do Until GUIGetMsg() = $GUI_EVENT_CLOSE Func ListView_RClick() Local $aHit $aHit = _GUICtrlListView_SubItemHitTest($hListView) If ($aHit[0] <> -1) Then ; Create a standard popup menu ; -------------------- To Do -------------------- $hMenu = _GUICtrlMenu_CreatePopup() _GUICtrlMenu_AddMenuItem($hMenu, "Edit", $idEdit) _GUICtrlMenu_AddMenuItem($hMenu, "Delete", $idDelete) ; ======================================================================== ; Shows how to capture the context menu selections ; ======================================================================== Switch _GUICtrlMenu_TrackPopupMenu($hMenu, $hListView, -1, -1, 1, 1, 2) Case $idEdit _DebugPrint("Edit: " & StringFormat("Item, SubItem [%d, %d]", $aHit[0], $aHit[1])) Case $idDelete _DebugPrint("Delete: " & StringFormat("Item, SubItem [%d, %d]", $aHit[0], $aHit[1])) EndSwitch _GUICtrlMenu_DestroyMenu($hMenu) Else ; Create a standard popup menu ; -------------------- To Do -------------------- $hMenu = _GUICtrlMenu_CreatePopup() _GUICtrlMenu_AddMenuItem($hMenu, "Add", $idAdd) ; ======================================================================== ; Shows how to capture the context menu selections ; ======================================================================== Switch _GUICtrlMenu_TrackPopupMenu($hMenu, $hListView, -1, -1, 1, 1, 2) Case $idAdd _DebugPrint("Add a New Item.") EndSwitch _GUICtrlMenu_DestroyMenu($hMenu) EndIf EndFunc ;==>ListView_RClick Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo $hWndListView = $hListView If Not IsHWnd($hListView) Then $hWndListView = GUICtrlGetHandle($hListView) $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) ;$iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView Switch $iCode Case $NM_RCLICK ; Sent by a list-view control when the user clicks an item with the left mouse button ListView_RClick() Return 0 EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Func _DebugPrint($s_text, $line = @ScriptLineNumber) ConsoleWrite( _ "!===========================================================" & @LF & _ "+======================================================" & @LF & _ "-->Line(" & StringFormat("%04d", $line) & "):" & @TAB & $s_text & @LF & _ "+======================================================" & @LF) EndFunc ;==>_DebugPrint Saludos1 point
-
You must check in this way: $iNewState = DllStructGetData($tInfo, "NewState") $iOldState = DllStructGetData($tInfo, "OldState") ;ConsoleWrite($iNewState &' (L: '&@ScriptLineNumber&')'&@CRLF) $iTem = DllStructGetData($tInfo, "Item") If Not BitAND($iOldState,$LVIS_SELECTED) And BitAND($iNewState,$LVIS_SELECTED) Then ToolTip('Item: '&$iTem&' selected') ; <----- Item X selected ConsoleWrite( 'Item: '&$iTem&' selected'&' (L: '&@ScriptLineNumber&')'&@CRLF) ElseIf BitAND($iOldState,$LVIS_SELECTED) And Not BitAND($iNewState,$LVIS_SELECTED) Then ToolTip('Item: '&$iTem&' unselected') ; <----- Item X unselected ConsoleWrite('Item: '&$iTem&' unselected' &' (L: '&@ScriptLineNumber&')'&@CRLF) EndIf1 point