krboun Posted January 1, 2012 Share Posted January 1, 2012 Hello my script: Func aktivace() $klic = InputBox("Aktivace","","","",200,150,0) Switch $klic case 0 FileOpen(@UserProfileDir & "\xxx.txt",2) $filedecrypt=_StringEncrypt(0,$klic,"abc") FileWrite(@UserProfileDir & "\xxx.txt",$filedecrypt) case 1 Exit EndSwitch EndFunc so i want to decrypt string from inputbox the problem is if the string to decrypt contais multiple lines, then script doesn´t write anything (encrypted strinng is always one line, if I'm correct) thanks for advice Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 1, 2012 Moderators Share Posted January 1, 2012 krboun,if the string to decrypt contais multiple linesBut you are using an InputBox to get the string - by definition you cannot get multiple lines from an Input control. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
krboun Posted January 1, 2012 Author Share Posted January 1, 2012 yes i know, look at _StringEncrypt in help there is examplee.g. i have a string containng a few lines of text, then i use _StringEncrypt(1,....) to engcrypt that multiple lines string. This function returns only 1 line of encrypted string always. This one line string i need to decrypt and filewrite with my script above.Is it clear now? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 1, 2012 Moderators Share Posted January 1, 2012 krboun,_StringEncrypt is pretty much deprecated nowadays - use the Crypt UDF instead. #include <Crypt.au3> _Crypt_Startup() ; To optimize performance start the crypt library. $sString = "Line 1" & @CRLF & "Line 2" & @CRLF & "line 3" ConsoleWrite($sString & @CRLF) Local $bEncrypted = _Crypt_EncryptData($sString, "fred", $CALG_RC4) ; Encrypt the text ConsoleWrite($bEncrypted & @CRLF) Local $bPlainText = _Crypt_DecryptData($bEncrypted, "fred", $CALG_RC4) ; Decrypt the text ConsoleWrite(BinaryToString($bPlainText) & @CRLF) _Crypt_Shutdown() ; Shutdown the crypt library.As you can see it handles multiple lines without a problem:Line 1 Line 2 Line 3 0xDB1560D4FA1209FAE8B619903D10E4948759174129A7 Line 1 Line 2 Line 3All clear? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
krboun Posted January 1, 2012 Author Share Posted January 1, 2012 (edited) i think i need something a little different my text file:fred luis peter this file i encrypt with _StringEncrypt function, output from this function is one long string and this string i put to inputbox (first post here) now i need to decrypt that long string again with _StringEncrypt function (different params of course), so output shoud be 3 lines with names, and that names i need to write to new file with 3 lines i dont understand why but my script (from the first post here) doesn´t work Edited January 1, 2012 by krboun Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 1, 2012 Moderators Share Posted January 1, 2012 krboun,I am confused. this file i encrypt with _StringEncrypt function, output from this function is one long string and this string i put to inputboxYou want to write the encrypted string to the InputBox? What on earth for? Please try and explain in detail what you are trying to do instead of just posting a short snippet of code that does not work. What I understand so far: You have a text file with names on several lines - you want to encrypt it and get back the separate lines when you decrypt, which is what the code I gave you above does. Where does the InputBox come into the picture? What does the user enter into the InputBox? How does this user input interact with the file?I am sure we can do what you want with the Crypt UDF - as I said before _StringEncrypt should not be used nowadays. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
PsaltyDS Posted January 2, 2012 Share Posted January 2, 2012 I think the encryption is a red herring. Choose a file handling method. Either FileOpen() and use the handle, or don't use FileOpen() and just refer to the string file path. Like this: Func aktivace() Local $klic, $hFile, $sFiledecrypt ; Get encrypted string $klic = InputBox("Aktivace", "", "", "", 200, 150, 0) Switch $klic Case 0 $hFile = FileOpen(@UserProfileDir & "xxx.txt", 2) $sFiledecrypt = _StringEncrypt(0, $klic, "abc") FileWrite($hFile, $sFiledecrypt) FileClose($hFile) Case Else Exit EndSwitch EndFunc ;==>aktivace Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
krboun Posted January 2, 2012 Author Share Posted January 2, 2012 (edited) oh, i am sorry forget it, i think mistake is somewhere here i just wanted to make simple progam which makes and reads crypted messages. I do not have any special reason to do that, i just study Autoit Also i studyed encption at my school so i wanted to to genarate a key which would allow to run program only at specific one PC, so i based that key on motherboard ID. i am amateur and autodidact so my questions could be confused and the answer so simple thakns for answers, i think i pregressed Edited January 2, 2012 by krboun 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