Ward Posted May 27, 2011 Author Share Posted May 27, 2011 I am having trouble with the AES, both AESTest files are giving this error: C:\Users\Tech\Desktop\AutoIt Machine Code Algorithm Collection\Encode\AES.au3(16,14) : ERROR: syntax error Global Const Enum Changing to:Global $AES_CBC_MODE, $AES_CFB_MODE, $AES_OFB_MODE resolves it and all is well. In AutoIt 3.3.6.1, this line is OK. If "Enum" is not supported, it may replace as following: Global Const $AES_CBC_MODE = 0 Global Const $AES_CFB_MODE = 1 Global Const $AES_OFB_MODE = 2 My only request at this point is for salt support, or is that already somehow possible? Thanks Ian You can write your own key derivation function. For example (PBKDF1): $Key = _MD5($Password & $Salt) For $i = 1 To 1000 $Key = _MD5($Hash) Next 新版 _ArrayAdd 的白痴作者,不管是誰,去死一死好了。 Link to comment Share on other sites More sharing options...
PaulDG Posted July 5, 2011 Share Posted July 5, 2011 HelloThe CHECKSUM.au3 is reporting that _CHECKSUM_Init() Does not exist - Should it be _CHECKSUM_Startup() ?Also in Hashesfiletest.au3, ThisDim $State = _HashInit(Eval('_HASH_' & $HashName))Is generating this error - "_HashInit() previously called with Const or expression on ByRef param(s)."I fixed withlocal $fixthis = Eval('_HASH_' & $HashName) Dim $State = _HashInit($fixthis)Appart from that they work a treat - Many thanksPaul Link to comment Share on other sites More sharing options...
dexto Posted July 12, 2011 Share Posted July 12, 2011 (edited) Just wanted to thank you. Very usefully and somewhat unbelievable. I don't know if its just me but LZF(.au3) crashes when decompressing PNG attached. ; ----------------------------------------------------------------------------- ; LZF Compression Machine Code UDF Example ; Purpose: Provide The Machine Code Version of LZF Algorithm In AutoIt ; Author: Ward ; LZF Copyright (C) 2000-2007 Marc Alexander Lehmann ; ----------------------------------------------------------------------------- #Include "LZF.au3" Dim $Original = Binary(FileRead("test.png")) Dim $Compressed = _LZF_Compress($Original) Dim $Decompressed = _LZF_Decompress($Compressed) Dim $Result = 'Original Size: ' & BinaryLen($Original) & @CRLF $Result &= 'Compressed Size: ' & BinaryLen($Compressed); & @CRLF $Result &= 'Decompress Succeed: ' & ($Decompressed = $Original) MsgBox(0, 'LZF Test', $Result) Edited July 12, 2011 by dexto Link to comment Share on other sites More sharing options...
Ward Posted July 14, 2011 Author Share Posted July 14, 2011 This script is OK on my computer both AutoIt x86 and x64. Is there anyone also crash on this script? 新版 _ArrayAdd 的白痴作者,不管是誰,去死一死好了。 Link to comment Share on other sites More sharing options...
trancexx Posted July 14, 2011 Share Posted July 14, 2011 Works fine for me on win7 x64 in both versions. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
BoonPek Posted August 8, 2011 Share Posted August 8, 2011 So, can this be somehow modified as to allow the decompressing/unzipping of files? Link to comment Share on other sites More sharing options...
Ward Posted August 9, 2011 Author Share Posted August 9, 2011 So, can this be somehow modified as to allow the decompressing/unzipping of files?These are only compression algorithm, not archiver. I have no intent to make machine code of archiver now.I think you can use MemoryDll UDF with some archiver DLL. 新版 _ArrayAdd 的白痴作者,不管是誰,去死一死好了。 Link to comment Share on other sites More sharing options...
joakim Posted August 9, 2011 Share Posted August 9, 2011 So, can this be somehow modified as to allow the decompressing/unzipping of files?If you take Ward's zlib udf; you can really create your own zip handling solution (compress/decompress) without any external dll. It works great, and I've used it myself to create such. Link to comment Share on other sites More sharing options...
KaFu Posted October 27, 2011 Share Posted October 27, 2011 (edited) Hi Ward, seems like your example "HASHESFileTest.au3" does not seem to work (for me a last ), it throws an ERROR: _HashInit() called with Const or expression on ByRef-param(s). Edit: Oh, has already been reported before ... I fixed with local $fixthis = Eval('_HASH_' & $HashName) Dim $State = _HashInit($fixthis) Here's an example for md5 (was asked by someone else). #include "MD5.au3" Dim $BufferSize = 0x100000 Dim $Filename = FileOpenDialog("Open File", "", "Any File (*.*)") If $Filename = "" Then Exit Dim $Timer = TimerInit() Dim $State = _MD5Init() Dim $FileHandle = FileOpen($Filename, 16) For $i = 1 To Ceiling(FileGetSize($Filename) / $BufferSize) _MD5Input($State, FileRead($FileHandle, $BufferSize)) Next Dim $Hash = _MD5Result($State) FileClose($FileHandle) ConsoleWrite($Hash & @TAB & TimerDiff($Timer) & @CRLF) Edited October 27, 2011 by KaFu OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
joakim Posted December 12, 2011 Share Posted December 12, 2011 (edited) @Ward Is there a known issue with crc32 on 64-bit? It crashes inside my Windows 7 x64 vm. Most of the other ones seems to work fine though. Edit: It seems to be my implementation of it that is the problem. But works fine on 32-bit though, so is strange.. Edited December 12, 2011 by joakim Link to comment Share on other sites More sharing options...
netegg Posted January 31, 2012 Share Posted January 31, 2012 (edited) well, good job! but, now, i have a puzzle. i try to use the _crypt* udf with some algorithm that marked in msdn but i cannot get the same result between them? #include'des.au3' #include<crypt.au3> local $CALG_DES = 0x00006601 ; http://msdn.microsoft.com/en-us/library/ms937014.aspx Dim $hKey=_Crypt_DeriveKey("The Key", $CALG_DES) Dim $Encrypt = _Crypt_EncryptData("The quick brown fox jumped over the lazy dog", $hKey, $CALG_USERKEY) & @crlf $Encrypt &= _DesEncrypt("The Key", "The quick brown fox jumped over the lazy dog") MsgBox(0, 'Encrypt String by DES Algorithm', $Encrypt) anybody would like to help? Edited January 31, 2012 by netegg Link to comment Share on other sites More sharing options...
ProgAndy Posted January 31, 2012 Share Posted January 31, 2012 (edited) The Crypto API derives a key from the given phrase, it does not use it directly. You'll have to use CryptImportKey, I have implemented a simple version here: http://www.autoit.de/index.php?page=Thread&postID=236228#post236228Edit: This is nearly correct, I don't know why the last 8 bytes differ. It is the same when using the JS-Implementation here: http://www.tero.co.uk/des/test.php 8 bytes are different to the other functions.expandcollapse popup#include "AlgorithmsEncodedes.au3" #include<crypt.au3> _Crypt_Startup() $Key = "The Key" $IV = "12345678" $data = Binary("The quick brown fox jumped over the lazy dog") Const $KP_IV = 1 ; local $CALG_DES = 0x00006601 ; http://msdn.microsoft.com/en-us/library/ms937014.aspx Dim $hKey=_CryptImportKey($CALG_DES, $Key, 8) Const $KP_MODE = 4 Const $CRYPT_MODE_CBC = 1 _CryptSetKeyParam($hKey, $KP_MODE, $CRYPT_MODE_CBC, 0, "dword*") _CryptSetKeyParam($hKey, $KP_IV, $IV, 0, "str") $Encrypt1 = _Crypt_EncryptData($data, $hKey, $CALG_USERKEY) $Encrypt2 = _DesEncrypt($Key, $data, $IV) MsgBox(0, 'Encrypt String by DES Algorithm', $Encrypt1 & @CRLF & _ BinaryMid($Encrypt2, 9) & @CRLF & _ ; The first 8 bytes are the IV when using _DesEncrypt $Encrypt2 ) _Crypt_DestroyKey($hKey) _Crypt_Shutdown() Func _CryptImportKey($CALG, $bKey, $iKeyLength = -1) ; Author: ProgAndy If $iKeyLength < 1 Then $iKeyLength = BinaryLen($bKey) Local $blob = DllStructCreate("align 1;BYTE bType;BYTE bVersion;WORD reserved;dword aiKeyAlg;dword keysize;byte key[" & $iKeyLength & "]") DllStructSetData($blob, 1, 0x8) DllStructSetData($blob, 2, 2) DllStructSetData($blob, 4, $CALG) DllStructSetData($blob, 5, $iKeyLength) DllStructSetData($blob, 6, Binary($bKey)) Local $aRet = DllCall(__Crypt_DllHandle(), "bool", "CryptImportKey", "handle", __Crypt_Context(), "ptr", DllStructGetPtr($blob), "dword", DllStructGetSize($blob), "ptr", 0, "dword", 0, "ptr*", 0) If @error Then Return SetError(2, @error, 0) Return SetError(Not $aRet[0], 0, $aRet[6]) EndFunc Func _CryptSetKeyParam($hKey, $iParam, $vValue, $iFlags=0, $sValType=Default) ; Author: ProgAndy If Not $sValType Or $sValType = Default Then $sValType = "ptr" Local $aRet = DllCall(__Crypt_DllHandle(), "bool", "CryptSetKeyParam", "handle", $hKey, "uint", $iParam, $sValType, $vValue, "dword", $iFlags) If @error Then Return SetError(2, @error, 0) Return SetError(Not $aRet[0], 0, $aRet[0]) EndFuncEdit: OK, That should be the result of different padding.Edit: You'll have to modify des.au3 to use PKCS#5 (#7) padding in order to decrypt it with the Crypto-API. The used bit-padding is not supported.http://en.wikipedia.org/wiki/Padding_%28cryptography%29#Padding_methodsFunc _DesEncryptCBC_Pad(ByRef $DesCtx, ByRef $IV, $Data) $Data = Binary($Data) Local $PadLen = 8 - Mod(BinaryLen($Data), 8) If $PadLen = 0 Then $PadLen = 8 Local $Pad = Binary('') For $i = 1 To $PadLen $Pad &= Binary(Chr($PadLen)) Next Return _DesEncryptCBC($DesCtx, $IV, $Data & $Pad) EndFunc Edited January 31, 2012 by ProgAndy *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes Link to comment Share on other sites More sharing options...
netegg Posted February 1, 2012 Share Posted February 1, 2012 (edited) Hi ProgAndy, Another question. Which one is exactly or more correct between with crypt api and with _des*(callwindowproc function)? I think that the answer will decide the trans- method! Thanks! Edited February 1, 2012 by netegg Link to comment Share on other sites More sharing options...
ProgAndy Posted February 1, 2012 Share Posted February 1, 2012 Both functions produce a valid result, the padding is not standardized. I suppose, most libraries use PKCS by default. *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes Link to comment Share on other sites More sharing options...
netegg Posted February 1, 2012 Share Posted February 1, 2012 (edited) ProgAndy, Thanks you for your answer! Ok, i will continue to try! And thank you for your other two functions(_crypt*)! More: Thanks again! I got it. You are quitely right! Edited February 2, 2012 by netegg Link to comment Share on other sites More sharing options...
wakillon Posted February 25, 2012 Share Posted February 25, 2012 (edited) Hi Ward As dexto had notified post #23 there is a problem with png files. I didn't try _LZF_Compress, but _LZMA_Compress Function ( LZMATest.au3 ). I have tried several filetype succesfully, but with png files i get true or false to Decompress result. After a moment i remark that only "bigger" png files return false. So i have resized a png until i get a true result : - LZMA Level 5 Test png file : Original Size: 95739 png 203x203 Compressed Size: 96767 Decompress Succeed: False - LZMA Level 5 Test png file : Original Size: 94880 png 201x201 Compressed Size: 95850 Decompress Succeed: True It's strange ... Edited February 26, 2012 by wakillon AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
Ward Posted February 25, 2012 Author Share Posted February 25, 2012 (edited) This error only happen when "Compressed Size" > "Original Size".In this situation, just don't use LZMA.If you want to fix that. You can modify _LZMA_Compress_Core function in LZMA.au3:;Local $OutputLen = $InputLen + 1024 Local $OutputLen = $InputLen + 4096 ; or more...Or you can check the $Ret[0] value at the end of this function, it can be$SZ_OK = 0 $SZ_ERROR_MEM = 2 $SZ_ERROR_PARAM = 5 $SZ_ERROR_OUTPUT_EOF = 7In your example, the $Ret[0] = 7 so the result is not OK. Edited February 25, 2012 by Ward 新版 _ArrayAdd 的白痴作者,不管是誰,去死一死好了。 Link to comment Share on other sites More sharing options...
wakillon Posted February 25, 2012 Share Posted February 25, 2012 (edited) Thanks for your quick answer ! Edited February 25, 2012 by wakillon AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
acidman Posted April 29, 2012 Share Posted April 29, 2012 This is great!! Nice work [u]My dream is to have a dream...[/u] Link to comment Share on other sites More sharing options...
titanfu Posted July 16, 2012 Share Posted July 16, 2012 I download AutoIt Machine Code Algorithm Collection.zip and test to run AESTest 2.au3.I got this error message.#Include "AES.au3" Dim $Key = Binary('0x11111111111111111111111111111111') Dim $Data = Binary('0x000102030405060708090A0B0C0D0E0F000102030405060708090A0B0C0D0E0F') Dim $Encrypt = _AesEncryptECB(_AesEncryptKey($Key), $Data) Dim $Decrypt = _AesDecryptECB(_AesDecryptKey($Key), $Encrypt) ConsoleWrite('=== Encrypt Two Block With AES128 ECB Mode ===' & @CRLF) ConsoleWrite('Encrypt: ' & $Encrypt & @CRLF & 'Decrypt: ' & $Decrypt & @CRLF & @CRLF)Error Message:>"D:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "D:\Ftproot\Software\Autoit 3.0\ScriptNew\AutoIt Machine Code Algorithm Collection\Encode\AESTest 2.au3" /UserParams +>19:08:50 Starting AutoIt3Wrapper v.2.1.0.33 Environment(Language:0404 Keyboard:00000404 OS:WIN_7/Service Pack 1 CPU:X64 OS:X64)>Running AU3Check (1.54.19.0) from:D:\Program Files (x86)\AutoIt3D:\AutoIt Machine Code Algorithm Collection\Encode\AESTest 2.au3(14,58) : ERROR: _AesEncryptECB() called with Const or expression on ByRef-param(s).Dim $Encrypt = _AesEncryptECB(_AesEncryptKey($Key), $Data)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^D:\AutoIt Machine Code Algorithm Collection\Encode\AES.au3(171,42) : REF: definition of _AesEncryptECB().Func _AesEncryptECB(ByRef $AesCtx, $Data)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^D:\AutoIt Machine Code Algorithm Collection\Encode\AESTest 2.au3(15,61) : ERROR: _AesDecryptECB() called with Const or expression on ByRef-param(s).Dim $Decrypt = _AesDecryptECB(_AesDecryptKey($Key), $Encrypt)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now