kudrow Posted October 23, 2014 Posted October 23, 2014 Hello, First off I feel really stupid because I cannot grasp how to create the function that I want to make. Looking at the examples in the help file just confuse me more. I am trying to simply build a function that will either A: Encrypt a string and return the value or B: Decrypt a string and return the value. I have encryption and decryption working fine I just want to create a function to do the work because I will be doing a lot of encrypting and decrypting in my script. I am working on a TCP register/login/logoff script if anyone is wondering. Thanks!
spudw2k Posted October 23, 2014 Posted October 23, 2014 If you posted some example code we could evaluate it and provide some suggestions. Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF
kudrow Posted October 23, 2014 Author Posted October 23, 2014 I wish I could delete this topic - I have been beating my head against the wall trying to figure this out but I just realized I need "return" to actually return data. #include <Crypt.au3> $convert="" $decryptData="" Func _Unlock() $decryptData = _Crypt_DecryptData ($convert, "theKeyUsed", $CALG_AES_256) Return $decryptData EndFunc This works when I call _Unlock() I guess I need to just use "if" statements to declare if I am decrypting or encrypting and return the value. I swear I over think things too much. Thanks for the help and feedback. All suggestions are welcome.
Danyfirex Posted October 23, 2014 Posted October 23, 2014 Just set a bool variable to see if you want to encript or decrypt. Saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut
spudw2k Posted October 23, 2014 Posted October 23, 2014 Just set a bool variable to see if you want to encript or decrypt. Saludos You could do that, but I'm a fan of making funcs modular as possible. I'd have one func do encryption and one do decryption, and depending on how I wanted to handle the "data", perhaps then pass it to a function that would do a condition statement based on a bool value (or other) and pass the data to the appropriate enc/dec func. Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF
kudrow Posted October 23, 2014 Author Posted October 23, 2014 Thank you for the feedback. Can either of you provide me an example of what your talking about? I know a bool is just a switch (true/false) but below is what I created and it does not work. Func _EncDec($enc=1) if $enc==1 Then $encrypt = _Crypt_EncryptData($DataToProcess, "TheKeyUsed", $CALG_AES_256) Return $encrypt Else $decryptData = _Crypt_DecryptData ($DataToProcess, "TheKeyUsed", $CALG_AES_256) Return $decryptData EndIf EndFunc when I call _EncDec() it throws an error and kills the script.
kylomas Posted October 23, 2014 Posted October 23, 2014 (edited) kudrow, Two things: What is the error? You should test @error when returning from UDF's kylomas edit: spelling Edited October 23, 2014 by kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill
Spider001 Posted October 23, 2014 Posted October 23, 2014 see example 2 at the help file Func StringEncrypt($bEncrypt, $sData, $sPassword) _Crypt_Startup() ; Start the Crypt library. Local $sReturn = '' If $bEncrypt Then ; If the flag is set to True then encrypt, otherwise decrypt. $sReturn = _Crypt_EncryptData($sData, $sPassword, $CALG_RC4) Else $sReturn = BinaryToString(_Crypt_DecryptData($sData, $sPassword, $CALG_RC4)) EndIf _Crypt_Shutdown() ; Shutdown the Crypt library. Return $sReturn EndFunc
kylomas Posted October 23, 2014 Posted October 23, 2014 To help we will need to see the source that created inbound.exe... Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill
kudrow Posted October 23, 2014 Author Posted October 23, 2014 I actually found my mistake. I was passing the wrong variable to the function so after the function returned bogus info it made the rest of my script crash. Spider that example is useful once I figured out the concept. Thank you everyone for the help.
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