datkewlguy Posted May 29, 2005 Share Posted May 29, 2005 im getting really frusterated, im trying to do something like this: For $i = 1 to round(sqrt(StringLen($sz_enc)), 0) For $i = 1 to StringLen($sz_enc) $sz_tmptxt = $sz_tmptxt & abcdef(StringMid($sz_enc, $i, 1)) Next Next but its not working... i can see why it should and shouldn't work... any ideas? Link to comment Share on other sites More sharing options...
Helge Posted May 29, 2005 Share Posted May 29, 2005 Both For's are using $i as variable.Just change one of them, to for example : $o Link to comment Share on other sites More sharing options...
datkewlguy Posted May 29, 2005 Author Share Posted May 29, 2005 Thankyou.. lol i feel really dumb... Link to comment Share on other sites More sharing options...
datkewlguy Posted May 29, 2005 Author Share Posted May 29, 2005 For $o = 1 to round(sqrt(StringLen($sz_enc)), 0) For $i = 1 to StringLen($sz_enc) $sz_tmptxt = $sz_tmptxt & abcdef(StringMid($sz_enc, $i, 1)) Next Next maybe its the rest of my code...but this isnt working either...any ideas? Link to comment Share on other sites More sharing options...
Helge Posted May 29, 2005 Share Posted May 29, 2005 My last comment was build on an expericene I recently had, but whenI posted I also did notice your use of the Round(..) and the StringLen(..)in your For's. Please read this :For...Next statements may be nested. The For loop terminates when the value of variable exceeds the stop threshold. If stepVal or stop is a variable, its value is only read the first time the loop executes.So my guess is that you are changing $sz_enc in one or both of theloops. Correct ? Link to comment Share on other sites More sharing options...
datkewlguy Posted May 29, 2005 Author Share Posted May 29, 2005 My last comment was build on an expericene I recently had, but whenI posted I also did notice your use of the Round(..) and the StringLen(..)in your For's. Please read this :So my guess is that you are changing $sz_enc in one or both of theloops. Correct ?<{POST_SNAPBACK}>no, what it's doing is it's reading the string length to encrypt accordingly, its for this new encryption algortithm, the code is below. But sz_enc is the length of the text. It's supposed to take the square root of that text and round up that number. Then that number is how many times it encrypts/decrypts based on the button you press (encrypt or decrypt)... But it keeps inflating the string and not doing what i want... the problem is in the for...next loops... Im having trouble nesting them.. take a look at the code below.expandcollapse popup#NoTrayIcon #include <GUIConstants.au3> $w = 300 $h = 200 $l = ( @DesktopWidth - $w ) / 2 $t = ( @DesktopHeight - $h ) / 2 $win = "abc encryption" $already = 0 $gui = GUICreate($win, $w, $h, $l, -1 * $h, $WS_MINIMIZEBOX + $WS_SYSMENU) $edit = GUICtrlCreateEdit("", 0, 0, $w - 5, $h - 51, $ES_WANTRETURN + $ES_MULTILINE + $WS_TABSTOP + $ES_AUTOVSCROLL + $ES_AUTOHSCROLL + $WS_VSCROLL + $WS_HSCROLL) $encrypt = GUICtrlCreateButton("E n c r y p t", 0, $h - 51, ($w / 3) - 2, 20) $decrypt = GUICtrlCreateButton("D e c r y p t", ($w / 3) - 2, $h - 51, ($w / 3) - 2, 20) $clipboard = GUICtrlCreateButton("C o p y", ($w / 3 * 2) - 4, $h - 51, ($w / 3) - 2, 20) GUISetState() GUISetBkColor("0xFFFFFF", $gui) GUICtrlSetState($edit, $GUI_FOCUS) WinSetOnTop($win, "", 1) WinSetTrans($win, "", 100) Global $n_ot = 0 For $i = -1 * $h to $t step 10 $n_ot = $n_ot + 1 Next $n_st = 0 For $i = -1 * $h to $t step 10 $n_st = $n_st + 1 WinMove($win, "", $l, $i) WinSetTrans($win, "", (255 * $n_st) / $n_ot) Next While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE outex() Exit Case WinActive($win) and not $already $already = 1 HotkeySet("^a", "selectall") Case not WinActive($win) and $already $already = 0 HotkeySet("^a") Case $msg = $decrypt $sz_enc = GUICtrlRead($edit) GUICtrlSetData($edit, "") GUICtrlSetData($edit, "Decrypting...") $sz_tmptxt = "" ;;;;;;;;here is the problem For $o = 1 to round(sqrt(StringLen($sz_enc)), 0) For $i = 1 to StringLen($sz_enc) $sz_tmptxt = $sz_tmptxt & abcdef(StringMid($sz_enc, $i, 1)) Next Next ;;;;;;;;here is the problem For $1 = 1 to round(sqrt(StringLen($sz_enc)), 0) $sz_tmptxt = _Scramble($sz_tmptxt) Next GUICtrlSetData($edit, "") GUICtrlSetData($edit, $sz_tmptxt) Case $msg = $encrypt $sz_dec = GUICtrlRead($edit) GUICtrlSetData($edit, "") GUICtrlSetData($edit, "Encrypting...") $sz_tmptxt = "" ;;;;;;;;here is the other problem For $o = 1 to round(sqrt(StringLen($sz_dec)), 0) For $i = 1 to StringLen($sz_dec) $sz_tmptxt = $sz_tmptxt & abcdef2(StringMid($sz_dec, $i, 1)) Next Next ;;;;;;;;here is the other problem For $i = 1 to round(sqrt(StringLen($sz_dec)), 0) $sz_tmptxt = _Unscramble($sz_tmptxt) Next GUICtrlSetData($edit, "") GUICtrlSetData($edit, $sz_tmptxt) Case $msg = $clipboard ClipPut(GUICtrlRead($edit)) EndSelect Sleep(1) Wend Func abcdef($sz_t) If StringIsUpper($sz_t) Then If $sz_t = "A" Then Return "B" If $sz_t = "B" Then Return "C" If $sz_t = "C" Then Return "D" If $sz_t = "D" Then Return "E" If $sz_t = "E" Then Return "F" If $sz_t = "F" Then Return "G" If $sz_t = "G" Then Return "H" If $sz_t = "H" Then Return "I" If $sz_t = "I" Then Return "J" If $sz_t = "J" Then Return "K" If $sz_t = "K" Then Return "L" If $sz_t = "L" Then Return "M" If $sz_t = "M" Then Return "N" If $sz_t = "N" Then Return "O" If $sz_t = "O" Then Return "P" If $sz_t = "P" Then Return "Q" If $sz_t = "Q" Then Return "R" If $sz_t = "R" Then Return "S" If $sz_t = "S" Then Return "T" If $sz_t = "T" Then Return "U" If $sz_t = "U" Then Return "V" If $sz_t = "V" Then Return "W" If $sz_t = "W" Then Return "X" If $sz_t = "X" Then Return "Y" If $sz_t = "Y" Then Return "Z" If $sz_t = "Z" Then Return "A" EndIf if $sz_t = "a" then return "b" if $sz_t = "b" then return "c" if $sz_t = "c" then return "d" if $sz_t = "d" then return "e" if $sz_t = "e" then return "f" if $sz_t = "f" then return "g" if $sz_t = "g" then return "h" if $sz_t = "h" then return "i" if $sz_t = "i" then return "j" if $sz_t = "j" then return "k" if $sz_t = "k" then return "l" if $sz_t = "l" then return "m" if $sz_t = "m" then return "n" if $sz_t = "n" then return "o" if $sz_t = "o" then return "p" if $sz_t = "p" then return "q" if $sz_t = "q" then return "r" if $sz_t = "r" then return "s" if $sz_t = "s" then return "t" if $sz_t = "t" then return "u" if $sz_t = "u" then return "v" if $sz_t = "v" then return "w" if $sz_t = "w" then return "x" if $sz_t = "x" then return "y" if $sz_t = "y" then return "z" if $sz_t = "z" then return "a" If $sz_t = "0" Then Return "2" If $sz_t = "2" Then Return "0" If $sz_t = "1" Then Return "3" If $sz_t = "3" Then Return "1" If $sz_t = "4" Then Return "6" If $sz_t = "6" Then Return "4" If $sz_t = "5" Then Return "7" If $sz_t = "7" Then Return "5" If $sz_t = "8" Then Return "9" If $sz_t = "9" Then Return "8" If $sz_t = ")" Then Return "@" If $sz_t = "@" Then Return ")" If $sz_t = "!" Then Return "#" If $sz_t = "#" Then Return "!" If $sz_t = "$" Then Return "^" If $sz_t = "^" Then Return "$" If $sz_t = "%" Then Return "&" If $sz_t = "&" Then Return "%" If $sz_t = "*" Then Return "(" If $sz_t = "(" Then Return "*" If $sz_t = "?" Then Return "+" If $sz_t = "+" Then Return "?" If $sz_t = " " Then Return ":" If $sz_t = ":" Then Return " " If $sz_t = @CR Then Return "" If $sz_t = @LF Then Return "¤" If $sz_t = "" Then Return @CR If $sz_t = "¤" Then Return @LF Return $sz_t EndFunc Func abcdef2($sz_t) If StringIsUpper($sz_t) Then If $sz_t = "B" Then Return "A" If $sz_t = "C" Then Return "B" If $sz_t = "D" Then Return "C" If $sz_t = "E" Then Return "D" If $sz_t = "F" Then Return "E" If $sz_t = "G" Then Return "F" If $sz_t = "H" Then Return "G" If $sz_t = "I" Then Return "H" If $sz_t = "J" Then Return "I" If $sz_t = "K" Then Return "J" If $sz_t = "L" Then Return "K" If $sz_t = "M" Then Return "L" If $sz_t = "N" Then Return "M" If $sz_t = "O" Then Return "N" If $sz_t = "P" Then Return "O" If $sz_t = "Q" Then Return "P" If $sz_t = "R" Then Return "Q" If $sz_t = "S" Then Return "R" If $sz_t = "T" Then Return "S" If $sz_t = "U" Then Return "T" If $sz_t = "V" Then Return "U" If $sz_t = "W" Then Return "V" If $sz_t = "X" Then Return "W" If $sz_t = "Y" Then Return "X" If $sz_t = "Z" Then Return "Y" If $sz_t = "A" Then Return "Z" EndIf if $sz_t = "b" then return "a" if $sz_t = "c" then return "b" if $sz_t = "d" then return "c" if $sz_t = "e" then return "d" if $sz_t = "f" then return "e" if $sz_t = "g" then return "f" if $sz_t = "h" then return "g" if $sz_t = "i" then return "h" if $sz_t = "j" then return "i" if $sz_t = "k" then return "j" if $sz_t = "l" then return "k" if $sz_t = "m" then return "l" if $sz_t = "n" then return "m" if $sz_t = "o" then return "n" if $sz_t = "p" then return "o" if $sz_t = "q" then return "p" if $sz_t = "r" then return "q" if $sz_t = "s" then return "r" if $sz_t = "t" then return "s" if $sz_t = "u" then return "t" if $sz_t = "v" then return "u" if $sz_t = "w" then return "v" if $sz_t = "x" then return "w" if $sz_t = "y" then return "x" if $sz_t = "z" then return "y" if $sz_t = "a" then return "z" If $sz_t = "0" Then Return "2" If $sz_t = "2" Then Return "0" If $sz_t = "1" Then Return "3" If $sz_t = "3" Then Return "1" If $sz_t = "4" Then Return "6" If $sz_t = "6" Then Return "4" If $sz_t = "5" Then Return "7" If $sz_t = "7" Then Return "5" If $sz_t = "8" Then Return "9" If $sz_t = "9" Then Return "8" If $sz_t = ")" Then Return "@" If $sz_t = "@" Then Return ")" If $sz_t = "!" Then Return "#" If $sz_t = "#" Then Return "!" If $sz_t = "$" Then Return "^" If $sz_t = "^" Then Return "$" If $sz_t = "%" Then Return "&" If $sz_t = "&" Then Return "%" If $sz_t = "*" Then Return "(" If $sz_t = "(" Then Return "*" If $sz_t = "?" Then Return "+" If $sz_t = "+" Then Return "?" If $sz_t = " " Then Return ":" If $sz_t = ":" Then Return " " If $sz_t = @CR Then Return "" If $sz_t = @LF Then Return "¤" If $sz_t = "" Then Return @CR If $sz_t = "¤" Then Return @LF Return $sz_t EndFunc Func selectall() Send("{SHIFTDOWN}{SHIFTUP}") Send("^{HOME}") Send("^+{END}") EndFunc Func _Scramble($sText) ;; Scramble a text string. $iLen = StringLen($sText) $Scrambled = "" For $i1 = 1 To Int($iLen / 2) $Scrambled = $Scrambled & StringMid($sText, $iLen - $i1 + 1, 1) & StringMid($sText, $i1, 1) Next; $i1 ; Pick up the odd character. If Mod($iLen, 2) Then $Scrambled = $Scrambled & StringMid($sText, $i1, 1) EndIf Return $Scrambled EndFunc;==>_Scramble Func _Unscramble($sText) ;; De-Scramble a Scrambled text that was scrambled by _Scramble. Local $iLen = StringLen($sText) Local $i, $Unscrambled1, $Unscrambled2 $Unscrambled1 = "" $Unscrambled2 = "" For $i1 = 1 To $iLen step 2 $Unscrambled1 = StringMid($sText, $i1, 1) & $Unscrambled1 $Unscrambled2 = $Unscrambled2 & StringMid($sText, $i1 + 1, 1) Next; $i1 ; Pick up the odd character. If Mod($iLen, 2) Then $Unscrambled1 = StringMid($sText, $i1, 1) & $Unscrambled1 EndIf $sText = $Unscrambled2 & $Unscrambled1 Return $Unscrambled2 & $Unscrambled1 EndFunc;==>_Unscramble Func outex() $n_st = 0 For $i = $t to $t + $t + $h step 10 $n_st = $n_st + 1 WinMove($win, "", $l, $i) WinSetTrans($win, "", 255 - ((255 * $n_st) / $n_ot)) Next EndFunc Link to comment Share on other sites More sharing options...
Nutster Posted May 30, 2005 Share Posted May 30, 2005 (edited) no, what it's doing is it's reading the string length to encrypt accordingly, its for this new encryption algortithm, the code is below. But sz_enc is the length of the text. It's supposed to take the square root of that text and round up that number. Then that number is how many times it encrypts/decrypts based on the button you press (encrypt or decrypt)... But it keeps inflating the string and not doing what i want... the problem is in the for...next loops... Im having trouble nesting them.. take a look at the code below.Code removed<{POST_SNAPBACK}>The Round function rounds off, not always up. Try adding 0.499999 to the number going into the Round function to get it to always round up.In the meantime, I add Ceiling and Floor to the beta. Edited May 30, 2005 by Nutster David NuttallNuttall Computer Consulting An Aquarius born during the Age of Aquarius AutoIt allows me to re-invent the wheel so much faster. I'm off to write a wizard, a wonderful wizard of odd... 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