Leaderboard
Popular Content
Showing content with the highest reputation on 06/01/2023 in all areas
-
I thought you were totally new to crypto a year ago when you posted basically the same script? Since you didn't ask a question, I can only assume that you would like for me to "help you" by creating an AutoIt example that does the same as your JavaScript example. The example script below is an accurate port of your JavaScript to AutoIt, using CryptoNG. #AutoIt3Wrapper_AU3Check_Parameters=-w 3 -w 4 -w 5 -w 6 -d #include <Constants.au3> #include <CryptoNG\CryptoNG.au3> ;<== Change path as needed n3wbie_example() Func n3wbie_example() ;String Vars Local $sMessage = "Encrypted string", _ $sPassword = "Secret password", _ $sDecryptedMessage = "" ;Binary Vars Local $xIV = _CryptoNG_GenerateRandom($CNG_BCRYPT_RNG_ALGORITHM, 16), _ $xSalt = _CryptoNG_GenerateRandom($CNG_BCRYPT_RNG_ALGORITHM, 16), _ $xEncryptionKey = _CryptoNG_PBKDF2($sPassword, $xSalt, 1000, $CNG_KEY_BIT_LENGTH_AES_256, $CNG_BCRYPT_SHA256_ALGORITHM), _ $xDecryptionKey = Binary(""), _ $xEncryptedMessage = Binary(""), _ $xFullEncryptedString = Binary("") ;Get encrypted message $xEncryptedMessage = _CryptoNG_AES_CBC_EncryptData($sMessage, $xEncryptionKey, $xIV) If @error Then Exit MsgBox($MB_ICONERROR, "_CryptoNG_AES_CBC_EncryptData Error", _CryptoNG_LastErrorMessage()) ;Prepend IV and Salt to encrypted message to create the full binary "encrypted string" $xFullEncryptedString = $xIV & $xSalt & $xEncryptedMessage ;Parse IV, Salt & Encrypted Message from full binary encrypted string in order to decrypt the message $xIV = BinaryMid($xFullEncryptedString, 1, 16) $xSalt = BinaryMid($xFullEncryptedString, 17, 16) $xEncryptedMessage = BinaryMid($xFullEncryptedString, 33) ;Generate decryption key using parsed values $xDecryptionKey = _CryptoNG_PBKDF2($sPassword, $xSalt, 1000, $CNG_KEY_BIT_LENGTH_AES_256, $CNG_BCRYPT_SHA256_ALGORITHM) ;Decrypt message using values parsed from full encrypted string $sDecryptedMessage = _CryptoNG_AES_CBC_DecryptData($xEncryptedMessage, $xDecryptionKey, $xIV) If @error Then Exit MsgBox($MB_ICONERROR, "_CryptoNG_AES_CBC_DecryptData Error", _CryptoNG_LastErrorMessage()) ;Display values ConsoleWrite("Message: " & $sMessage & @CRLF) ConsoleWrite(@CRLF) ConsoleWrite("Password: " & $sPassword & @CRLF) ConsoleWrite("IV: " & $xIV & @CRLF) ConsoleWrite("PBKDF2 Salt: " & $xSalt & @CRLF) ConsoleWrite("Generated Encryption Key: " & $xEncryptionKey & @CRLF) ConsoleWrite(@CRLF) ConsoleWrite("Encrypted Message: " & $xEncryptedMessage & @CRLF) ConsoleWrite("Full Encrypted String: " & $xFullEncryptedString & @CRLF) ConsoleWrite(@CRLF) ConsoleWrite("Generated decryption key: " & $xDecryptionKey & @CRLF) ConsoleWrite(@CRLF) ConsoleWrite("Decrypted Message: " & $sDecryptedMessage & @CRLF) EndFunc Console output: (A new encryption key is generated each time you run the script, so most values will be different than below.) Message: Encrypted string Password: Secret password IV: 0x8750BA05ED7BAE8E388456511813D208 PBKDF2 Salt: 0x96FBE67B0BAB75CE7E80DA8FFFE2AEB2 Generated Encryption Key: 0xC5FA70FF15D3C4193BDEA881DB8F34453015BD517174E96A2A24EF70A96FA984 Encrypted Message: 0x2262B52072EB0F8C966EDF4F8939F8D0DF984E0A2313726D79A46C23649A74BA Full Encrypted String: 0x8750BA05ED7BAE8E388456511813D20896FBE67B0BAB75CE7E80DA8FFFE2AEB22262B52072EB0F8C966EDF4F8939F8D0DF984E0A2313726D79A46C23649A74BA Generated decryption key: 0xC5FA70FF15D3C4193BDEA881DB8F34453015BD517174E96A2A24EF70A96FA984 Decrypted Message: Encrypted string2 points
-
There is a bug in @Subz code. Replace If StringStripWS($mydata[$j][0],7) = StringStripWS($mydata2,7) Then $mydata[$j][4]=$mydata2[$i][1] with If StringStripWS($mydata[$j][0],7) = StringStripWS($mydata2[$i][0],7) Then $mydata[$j][4]=$mydata2[$i][1]2 points
-
Lots of work on my program again today, though half of that at least, would have been me investigating GDIPlus commands and usage, and I managed to finally scrape a few of them together and get a good result. I worked on the BACKUP IMAGES code first, completed that and did a full backup of device images to a PC folder, a sub-folder of 'Ebook Covers', named 'Backups', inside single author named sub-folders. Then I worked on code that checks for the USB connected Kobo device, which resulted in me adding a couple more elements to the Results window, below the 'Cover Images - Source' list, which you can see in the above screenshot was the FIND KOBO DEVICE button and Input field. Then I started work on the code for the ADD button, culminating in some research at the AutoIt Forum for GDIPlus commands that would let me alter the DPI if needed and the JPG quality. I'm not using the latest AutoIt (couple of point versions behind), so I don't know if something like the old _GDIPlus_BitmapSetResolution command exists again. No idea why it was removed or what it might have been replaced with? Anyway, I needed to make a simple 'GDIP.au3' Include file just for that function, which I had discovered in my searches. I ran out of time to complete the ADD button code today, but it currently creates a 'Test,jpg' file in the script directory, for the first of the three image files (largest one). The DPI (300 x 300) and JPG Quality (60%) is being set. At this point, until I discover otherwise, I am working on the notion that file size, rather than image dimensions, is the most important consideration, along with probably DPI resolution. From what I have seen with device folders that have all three image files, the exact dimensions while roughly similar (large, medium, small) are all over the place. And as some of my source files are quite large, storage space used up on the Kobo device then becomes quite important. You see something like the following when you click the ADD button. DOWNLOAD Kobo Cover Fixer.au3 (54 downloads) SEE THE FIRST POST in this topic for the latest version. 62.4 kB GDIP.au3 If anyone can improve upon the following GDIPlus code and share, that would be great and much appreciated. ; BIG THANKS for bits of the following code to UEZ, funkey & Synapsee ; https://www.autoitscript.com/forum/topic/120163-set-pixels-per-inch-using-gdi/?do=findComment&comment=834906 ; https://www.autoitscript.com/forum/topic/164388-changing-the-dpi-of-a-bmp/?do=findComment&comment=1198966 ; https://www.autoitscript.com/forum/topic/183492-problem-when-manipulating-images-with-different-dpi-using-gdiplus/?do=findComment&comment=1317885 Local $CLSID, $hBitmap, $hBMP, $pData, $result, $savfle, $tData, $tGUID, $tParams $savfle = @ScriptDir & "\Test.jpg" _GDIPlus_Startup() $hBitmap = _GDIPlus_BitmapCreateFromFile($covimg) $hBMP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) _GDIPlus_BitmapDispose($hBitmap) $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hBMP) _WinAPI_DeleteObject($hBMP) $result = _GDIPlus_BitmapSetResolution($hBitmap, 300, 300) $CLSID = _GDIPlus_EncodersGetCLSID("JPG") $tGUID = _WinAPI_GUIDFromString($CLSID) $tParams = _GDIPlus_ParamInit(1) $tData = DllStructCreate("int Quality") DllStructSetData($tData, "Quality", 60) $pData = DllStructGetPtr($tData) _GDIPlus_ParamAdd($tParams, $GDIP_EPGQUALITY, 1, $GDIP_EPTLONG, $pData) _GDIPlus_ImageSaveToFileEx($hBitmap, $savfle, $CLSID, $tParams) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_Shutdown()1 point
-
@drbob001 Here to get you started : #include <Array.au3> #include <Constants.au3> Opt("MustDeclareVars", True) HotKeySet("{ESC}", Terminate) Global $aKey = IniReadSection("Test.ini", "Keys") ;_ArrayDisplay($aKey) For $i = 1 To $aKey[0][0] If Not HotKeySet($aKey[$i][0], SendPhrase) Then Exit MsgBox($MB_OK, "Error", "Invalid key set") Next While Sleep(100) WEnd Func SendPhrase() For $i = 1 To $aKey[0][0] If $aKey[$i][0] = @HotKeyPressed Then Return Send($aKey[$i][1]) Next EndFunc Func Terminate() Exit EndFunc An example of the ini file :Test.ini1 point
-
Welcome to AutoIt and the forum! What have you tried so far? Maybe this site helps? https://wiki.documentfoundation.org/Documentation/BASIC_Guide#Formatting1 point
-
For sure the CPU / HDD usage will increase. My CPU usage is ~1-5% but memory consumption is ~15 mb now. ;Coded by UEZ build 2023-05-31 #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> AutoItSetOption("GUIOnEventMode", 1) _GDIPlus_Startup() Global $i, $hImage, $hGDIBitmap, $hObjOld, $bExit = False Global Const $hGUI = GUICreate("Test", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP) GUISetState() Global Const $hDC = _WinAPI_GetDC($hGUI), _ $hGfxDC = _WinAPI_CreateCompatibleDC($hDC) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") $i = 1 Do $hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\Test\" & $i & ".jpg") $i += 1 If $i > 169 Then $i = 1 $hGDIBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) _GDIPlus_ImageDispose($hImage) $hObjOld = _WinAPI_SelectObject($hGfxDC, $hGDIBitmap) _WinAPI_StretchBlt($hDC, 0, 0, @DesktopWidth, @DesktopHeight, $hGfxDC, 0, 0, 1280, 720, $SRCCOPY) ;resize _WinAPI_SelectObject($hGfxDC, $hObjOld) _WinAPI_DeleteObject($hGDIBitmap) If $bExit Then ExitLoop Until Not Sleep(10) _WinAPI_ReleaseDC($hGUI, $hDC) _WinAPI_DeleteDC($hGfxDC) _GDIPlus_Shutdown() Func _Exit() $bExit = True EndFunc1 point
-
Try looping within a loop or you could try _ArrayFind function ;~ Loop through $mydata2 For $i = 1 To UBound($mydata2)-1 If StringStripWS($mydata2[$i][0],7) = "" Then ContinueLoop ;~ Loop through $mydata For $j = 1 To UBound($mydata)-1 ;~ Check if $mydata[x][column 0] = $mydata2[x][column 0] and set $mydata[x][column 4] to $mydata2[x][column 1] If StringStripWS($mydata[$j][0],7) = StringStripWS($mydata2,7) Then $mydata[$j][4]=$mydata2[$i][1] Next Next1 point
-
Midi UDF
PeterVerbeek reacted to MattyD for a topic
Hi all, This may be a bit premature, but here is release 1.6. SCITE integration: - The helpfile can be brought up with the f1 key when on a _midi_* or _midiAPI_* funcation. Based on the fantastic work of @water . - Alternate data streams will be stripped when the helpfile is installed to localappdata. This fixes the "unblock file" problem detailed previously. API: - Fixed alignment issue with the midihdr tag when compiling as x64. (the [MM_]MOM_POSITIONCB callback can now correctly locate midi events in a buffer.) UDF: - Fixed input buffers not being unprepared before disposal when closing devices. *** EXPEREMENTAL *** - Output devices are now opened as streaming devices. - Added ability to record and playback midi messages. - Added ability to write and playback standard midi files. - Added a mechanism for recieving "cue" and "marker" meta events during playback. - Added ability to modify playback tempo Be aware that the experimental features are still very early in development, and implementation is likely change drastically down the track! If anyone is looking for a ealier version of the project, you'll find all previous releases on the sourceforge page. Happy coding, Matt1 point