zizou86 Posted October 13, 2011 Share Posted October 13, 2011 Hi, I am aware that AutoIt has no support for DES encryption and I am looking for a script that can help. I am very reluctant to code the entire DES out myself in AutoIt as that is going to take a tremendous amount of time and kind of reinvents the wheel. I know that Windows has some form of API for DES. However, I tried a DLL call and there is the _Crypt_DeriveKey function that helps you generate a key from a short password. I cannot use this as I already have a binary/hex key and I will like to use this key for my DES encryption. Hence, I found out that the API has CryptImportKey function. But I am extremely unsure of how to go about using it as I am not very good at Dll calls. http://msdn.microsoft.com/en-us/library/windows/desktop/aa380207(v=VS.85).aspx http://msdn.microsoft.com/en-us/library/windows/desktop/aa382383(v=VS.85).aspx Here's what I have tried (its pretty much translations of the 2nd link posted above): $aRet = DllCall("advapi32.dll", 'int', 'CryptAcquireContext', 'ptr*', 0, 'ptr', 0, 'ptr', 0, 'dword', 1, 'dword', 0xF0000000) Local $DesKeyBlob[20] = [0x08,0x02,0x00,0x00,0x01,0x66,0x00,0x00,0x08,0x00,0x00,0x00,0xf1,0x0e,0x25,0x7c,0x6b,0xce,0x0d,0x34] Local $phKey= DllStructCreate("uint") Local $phKey= DllStructCreate("uint") Local $ret= DllCall("Advapi32.dll","int","CryptImportKey","ptr*",$hContext,"int",$DesKeyBlob,"dword",BinaryLen($DesKeyBlob),"ptr",0,"dword",1,"ptr*", DllStructGetPtr($phKey)) My codes reported no error but the key is always 0. I tried to do an exportKey after the import and once more, the key is 0. I have honestly no idea how I can fix this as I have not really used AutoIt and DLLcalls together before. Can some kind soul please point me to the right direction please? I understand that DES is obsolette and I really should use AES. But I do really need to use DES instead of AES for this. I really appreciate if someone can show me an example of this so I can continue with my programming work for the other forms of encryption. Thank you. Regards. Link to comment Share on other sites More sharing options...
KaFu Posted October 13, 2011 Share Posted October 13, 2011 Afaik Wards most excellent supports DES. OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
zizou86 Posted October 13, 2011 Author Share Posted October 13, 2011 (edited) Sorry I seem unable to edit my codes. The codes I posted above lacked the code tags so here I am reposting here for ease of reading of my AutoIT codes: $aRet = DllCall("advapi32.dll", 'int', 'CryptAcquireContext', 'ptr*', 0, 'ptr', 0, 'ptr', 0, 'dword', 1, 'dword', 0xF0000000) Local $DesKeyBlob[20] = [0x08,0x02,0x00,0x00,0x01,0x66,0x00,0x00,0x08,0x00,0x00,0x00,0xf1,0x0e,0x25,0x7c,0x6b,0xce,0x0d,0x34] Local $phKey= DllStructCreate("uint") Local $phKey= DllStructCreate("uint") Local $ret= DllCall("Advapi32.dll","int","CryptImportKey","ptr*",$hContext,"int",$DesKeyBlob,"dword",BinaryLen($DesKeyBlob),"ptr",0,"dword",1,"ptr*", DllStructGetPtr($phKey Edited October 13, 2011 by zizou86 Link to comment Share on other sites More sharing options...
Mat Posted October 13, 2011 Share Posted October 13, 2011 If I remember rightly, there is a built in library with AutoIt: Crypt.au3. I think that calls the same functions as above (it was definitely advapi anyway) so it might do what you want. AutoIt Project Listing 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