Kjodiz Posted September 23, 2011 Share Posted September 23, 2011 I'm trying to make a simple encryption script, but I can't get it to work. Everything I get is an empty file. Here's what I've gotten so far: $TextFileName = "Passwords.txt" $FindText = "a" $ReplaceText = "b" $FileContents = FileRead($TextFileName) $FileContents = StringReplace($FileContents,$FindText,$ReplaceText) FileDelete($TextFileName) FileWrite($TextFileName,$FileContents) Link to comment Share on other sites More sharing options...
nitekram Posted September 23, 2011 Share Posted September 23, 2011 I think you need to read a line and then each char of the line to be able to replace characters. 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator Link to comment Share on other sites More sharing options...
Envoi Posted September 23, 2011 Share Posted September 23, 2011 Your script works as written. Just make sure that the file you're reading is in the same directory as the script you're running. Or, you'll need to specify where the original exists. The reason you're getting a blank file (I'm guessing) is because your original file is NOT in the same directory as your script. Thus, when it runs, FileRead is returning nothing since it can't find the file, which makes $FileContents blank, then FileWrite is creating the file and filling it with nothing. Hope that helps. Link to comment Share on other sites More sharing options...
sleepydvdr Posted September 23, 2011 Share Posted September 23, 2011 #include <File.au3> $TextFileName = "Passwords.txt" $FindText = "a" $ReplaceText = "b" _ReplaceStringInFile($TextFileName,$FindText,$ReplaceText) #include <ByteMe.au3> Link to comment Share on other sites More sharing options...
Kjodiz Posted September 24, 2011 Author Share Posted September 24, 2011 Envoi, I had the script and the file in the same folder. Sleepy, I'll try your version when i get back home Thanks for your help everyone Link to comment Share on other sites More sharing options...
Kjodiz Posted September 25, 2011 Author Share Posted September 25, 2011 Sleepy, Tried your version, and it works! I'll post the finished version when I'm done Link to comment Share on other sites More sharing options...
Rogue5099 Posted September 25, 2011 Share Posted September 25, 2011 (edited) I made this awhile back, it converts letters to corrisponding numbers then puts a ":" between each letter to avoid wrong decryption. This also maintains CaSe SeNsiTiVe encryptions. You can take out string to binary to shorten or have each number be +x amount and decrypt with -x amount. to maintain same string length. Plenty of options! expandcollapse popup#include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> GUICreate("Encrypt Decrypt - by Rogue5099", 578, 326) $Edit1 = GUICtrlCreateEdit("", 16, 56, 241, 209, BitOR($ES_WANTRETURN, $WS_VSCROLL, $ES_AUTOVSCROLL)) GUICtrlSetData(-1, "") $Edit2 = GUICtrlCreateEdit("", 312, 56, 249, 217, BitOr($ES_WANTRETURN, $WS_VSCROLL, $ES_AUTOVSCROLL)) GUICtrlSetData(-1, "") $Encrypt = GUICtrlCreateButton("Encrypt", 56, 288, 131, 25, $WS_GROUP) $Decrypt = GUICtrlCreateButton("Decrypt", 360, 288, 131, 25, $WS_GROUP) $Label1 = GUICtrlCreateLabel("Text to be Encrypted", 24, 16, 225, 33) GUICtrlSetFont(-1, 18, 400, 0, "MS Sans Serif") $Label2 = GUICtrlCreateLabel("Text to be Decrypted", 312, 16, 227, 33) GUICtrlSetFont(-1, 18, 400, 0, "MS Sans Serif") GUISetState(@SW_SHOW) Global $LowerCase[130], $UpperCase[91], $Number[7000], $Number2[7000], $Count While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Encrypt Encrypt() Case $Decrypt Decrypt() EndSwitch WEnd Func Encrypt() $Message = GUICtrlRead($Edit1) GUICtrlSetData($Edit2, "") For $i = 97 To 122 $LowerCase[$i] = Chr($i) If StringInStr($Message, $LowerCase[$i]) Then $Message = StringReplace($Message, $LowerCase[$i], StringFormat("%03u",$i) & ":", 0, 1) EndIf Next For $i = 65 To 90 $UpperCase[$i] = Chr($i) If StringInStr($Message, $UpperCase[$i]) Then $Message = StringReplace($Message, $UpperCase[$i], StringFormat("%03u",$i) & ":", 0, 1) EndIf Next GUICtrlSetData($Edit2, StringTrimLeft(StringToBinary($Message, 2), 2)) EndFunc Func Decrypt() $Message = BinaryToString("0x" & GUICtrlRead($Edit2), 2) GUICtrlSetData($Edit1, "") For $i = 97 To 122 $LowerCase[$i] = StringFormat("%03u", $i) If StringInStr($Message, $LowerCase[$i] & ":") Then $Message = StringReplace($Message, $LowerCase[$i] & ":", Chr($i), 0, 1) EndIf Next For $i = 65 To 90 $UpperCase[$i] = StringFormat("%03u", $i) If StringInStr($Message, $UpperCase[$i] & ":") Then $Message = StringReplace($Message, $UpperCase[$i] & ":", Chr($i), 0, 1) EndIf Next GUICtrlSetData($Edit1, $Message) EndFunc My script Encrypted: 23003100300035003A003100310030003A003000390039003A003100300038003A003100310037003A003100300030003A003100300031003A0020003C003000360039003A003100300030003A003100300035003A003100310036003A003000360037003A003100310031003A003100310030003A003100310035003A003100310036003A003000390037003A003100310030003A003100310036003A003100310035003A002E003000390037003A003100310037003A0033003E000D000A0023003100300035003A003100310030003A003000390039003A003100300038003A003100310037003A003100300030003A003100300031003A0020003C003000370031003A003000380035003A003000370033003A003000360037003A003100310031003A003100310030003A003100310035003A003100310036003A003000390037003A003100310030003A003100310036003A003100310035003A003000360039003A003100320030003A002E003000390037003A003100310037003A0033003E000D000A0023003100300035003A003100310030003A003000390039003A003100300038003A003100310037003A003100300030003A003100300031003A0020003C003000380037003A003100300035003A003100310030003A003100300030003A003100310031003A003100310039003A003100310035003A003000360037003A003100310031003A003100310030003A003100310035003A003100310036003A003000390037003A003100310030003A003100310036003A003100310035003A002E003000390037003A003100310037003A0033003E000D000A003000370031003A003000380035003A003000370033003A003000360037003A003100310034003A003100300031003A003000390037003A003100310036003A003100300031003A00280022003000360039003A003100310030003A003000390039003A003100310034003A003100320031003A003100310032003A003100310036003A0020003000360038003A003100300031003A003000390039003A003100310034003A003100320031003A003100310032003A003100310036003A0020002D0020003000390038003A003100320031003A0020003000380032003A003100310031003A003100300033003A003100310037003A003100300031003A00350030003900390022002C0020003500370038002C00200033003200360029000D000A0024003000360039003A003100300030003A003100300035003A003100310036003A00310020003D0020003000370031003A003000380035003A003000370033003A003000360037003A003100310036003A003100310034003A003100300038003A003000360037003A003100310034003A003100300031003A003000390037003A003100310036003A003100300031003A003000360039003A003100300030003A003100300035003A003100310036003A002800220022002C002000310036002C002000350036002C0020003200340031002C0020003200300039002C0020003000360036003A003100300035003A003100310036003A003000370039003A003000380032003A00280024003000360039003A003000380033003A005F003000380037003A003000360035003A003000370038003A003000380034003A003000380032003A003000360039003A003000380034003A003000380035003A003000380032003A003000370038003A002C00200024003000380037003A003000380033003A005F003000380036003A003000380033003A003000360037003A003000380032003A003000370039003A003000370036003A003000370036003A002C00200024003000360039003A003000380033003A005F003000360035003A003000380035003A003000380034003A003000370039003A003000380036003A003000380033003A003000360037003A003000380032003A003000370039003A003000370036003A003000370036003A00290029000D000A003000370031003A003000380035003A003000370033003A003000360037003A003100310036003A003100310034003A003100300038003A003000380033003A003100300031003A003100310036003A003000360038003A003000390037003A003100310036003A003000390037003A0028002D0031002C0020002200220029000D000A0024003000360039003A003100300030003A003100300035003A003100310036003A00320020003D0020003000370031003A003000380035003A003000370033003A003000360037003A003100310036003A003100310034003A003100300038003A003000360037003A003100310034003A003100300031003A003000390037003A003100310036003A003100300031003A003000360039003A003100300030003A003100300035003A003100310036003A002800220022002C0020003300310032002C002000350036002C0020003200340039002C0020003200310037002C0020003000360036003A003100300035003A003100310036003A003000370039003A003100310034003A00280024003000360039003A003000380033003A005F003000380037003A003000360035003A003000370038003A003000380034003A003000380032003A003000360039003A003000380034003A003000380035003A003000380032003A003000370038003A002C00200024003000380037003A003000380033003A005F003000380036003A003000380033003A003000360037003A003000380032003A003000370039003A003000370036003A003000370036003A002C00200024003000360039003A003000380033003A005F003000360035003A003000380035003A003000380034003A003000370039003A003000380036003A003000380033003A003000360037003A003000380032003A003000370039003A003000370036003A003000370036003A00290029000D000A003000370031003A003000380035003A003000370033003A003000360037003A003100310036003A003100310034003A003100300038003A003000380033003A003100300031003A003100310036003A003000360038003A003000390037003A003100310036003A003000390037003A0028002D0031002C0020002200220029000D000A0024003000360039003A003100310030003A003000390039003A003100310034003A003100320031003A003100310032003A003100310036003A0020003D0020003000370031003A003000380035003A003000370033003A003000360037003A003100310036003A003100310034003A003100300038003A003000360037003A003100310034003A003100300031003A003000390037003A003100310036003A003100300031003A003000360036003A003100310037003A003100310036003A003100310036003A003100310031003A003100310030003A00280022003000360039003A003100310030003A003000390039003A003100310034003A003100320031003A003100310032003A003100310036003A0022002C002000350036002C0020003200380038002C0020003100330031002C002000320035002C00200024003000380037003A003000380033003A005F003000370031003A003000380032003A003000370039003A003000380035003A003000380030003A0029000D000A0024003000360038003A003100300031003A003000390039003A003100310034003A003100320031003A003100310032003A003100310036003A0020003D0020003000370031003A003000380035003A003000370033003A003000360037003A003100310036003A003100310034003A003100300038003A003000360037003A003100310034003A003100300031003A003000390037003A003100310036003A003100300031003A003000360036003A003100310037003A003100310036003A003100310036003A003100310031003A003100310030003A00280022003000360038003A003100300031003A003000390039003A003100310034003A003100320031003A003100310032003A003100310036003A0022002C0020003300360030002C0020003200380038002C0020003100330031002C002000320035002C00200024003000380037003A003000380033003A005F003000370031003A003000380032003A003000370039003A003000380035003A003000380030003A0029000D000A0024003000370036003A003000390037003A003000390038003A003100300031003A003100300038003A00310020003D0020003000370031003A003000380035003A003000370033003A003000360037003A003100310036003A003100310034003A003100300038003A003000360037003A003100310034003A003100300031003A003000390037003A003100310036003A003100300031003A003000370036003A003000390037003A003000390038003A003100300031003A003100300038003A00280022003000380034003A003100300031003A003100320030003A003100310036003A0020003100310036003A003100310031003A0020003000390038003A003100300031003A0020003000360039003A003100310030003A003000390039003A003100310034003A003100320031003A003100310032003A003100310036003A003100300031003A003100300030003A0022002C002000320034002C002000310036002C0020003200320035002C0020003300330029000D000A003000370031003A003000380035003A003000370033003A003000360037003A003100310036003A003100310034003A003100300038003A003000380033003A003100300031003A003100310036003A003000370030003A003100310031003A003100310030003A003100310036003A0028002D0031002C002000310038002C0020003400300030002C00200030002C00200022003000370037003A003000380033003A0020003000380033003A003000390037003A003100310030003A003100310035003A0020003000380033003A003100300031003A003100310034003A003100300035003A003100300032003A00220029000D000A0024003000370036003A003000390037003A003000390038003A003100300031003A003100300038003A00320020003D0020003000370031003A003000380035003A003000370033003A003000360037003A003100310036003A003100310034003A003100300038003A003000360037003A003100310034003A003100300031003A003000390037003A003100310036003A003100300031003A003000370036003A003000390037003A003000390038003A003100300031003A003100300038003A00280022003000380034003A003100300031003A003100320030003A003100310036003A0020003100310036003A003100310031003A0020003000390038003A003100300031003A0020003000360038003A003100300031003A003000390039003A003100310034003A003100320031003A003100310032003A003100310036003A003100300031003A003100300030003A0022002C0020003300310032002C002000310036002C0020003200320037002C0020003300330029000D000A003000370031003A003000380035003A003000370033003A003000360037003A003100310036003A003100310034003A003100300038003A003000380033003A003100300031003A003100310036003A003000370030003A003100310031003A003100310030003A003100310036003A0028002D0031002C002000310038002C0020003400300030002C00200030002C00200022003000370037003A003000380033003A0020003000380033003A003000390037003A003100310030003A003100310035003A0020003000380033003A003100300031003A003100310034003A003100300035003A003100300032003A00220029000D000A003000370031003A003000380035003A003000370033003A003000380033003A003100300031003A003100310036003A003000380033003A003100310036003A003000390037003A003100310036003A003100300031003A00280040003000380033003A003000380037003A005F003000380033003A003000370032003A003000370039003A003000380037003A0029000D000A000D000A003000370031003A003100300038003A003100310031003A003000390038003A003000390037003A003100300038003A00200024003000370036003A003100310031003A003100310039003A003100300031003A003100310034003A003000360037003A003000390037003A003100310035003A003100300031003A005B003100330030005D002C00200024003000380035003A003100310032003A003100310032003A003100300031003A003100310034003A003000360037003A003000390037003A003100310035003A003100300031003A005B00390031005D002C00200024003000370038003A003100310037003A003100300039003A003000390038003A003100300031003A003100310034003A005B0037003000300030005D002C00200024003000370038003A003100310037003A003100300039003A003000390038003A003100300031003A003100310034003A0032005B0037003000300030005D002C00200024003000360037003A003100310031003A003100310037003A003100310030003A003100310036003A000D000A000D000A003000380037003A003100300034003A003100300035003A003100300038003A003100300031003A00200031000D000A00090024003100310030003A003000370037003A003100310035003A003100300033003A0020003D0020003000370031003A003000380035003A003000370033003A003000370031003A003100300031003A003100310036003A003000370037003A003100310035003A003100300033003A00280029000D000A0009003000380033003A003100310039003A003100300035003A003100310036003A003000390039003A003100300034003A00200024003100310030003A003000370037003A003100310035003A003100300033003A000D000A00090009003000360037003A003000390037003A003100310035003A003100300031003A00200024003000370031003A003000380035003A003000370033003A005F003000360039003A003000380036003A003000360039003A003000370038003A003000380034003A005F003000360037003A003000370036003A003000370039003A003000380033003A003000360039003A000D000A000900090009003000360039003A003100320030003A003100300035003A003100310036003A000D000A00090009003000360037003A003000390037003A003100310035003A003100300031003A00200024003000360039003A003100310030003A003000390039003A003100310034003A003100320031003A003100310032003A003100310036003A000D000A000900090009003000360039003A003100310030003A003000390039003A003100310034003A003100320031003A003100310032003A003100310036003A00280029000D000A00090009003000360037003A003000390037003A003100310035003A003100300031003A00200024003000360038003A003100300031003A003000390039003A003100310034003A003100320031003A003100310032003A003100310036003A000D000A000900090009003000360038003A003100300031003A003000390039003A003100310034003A003100320031003A003100310032003A003100310036003A00280029000D000A0009003000360039003A003100310030003A003100300030003A003000380033003A003100310039003A003100300035003A003100310036003A003000390039003A003100300034003A000D000A003000380037003A003000360039003A003100310030003A003100300030003A000D000A000D000A003000370030003A003100310037003A003100310030003A003000390039003A0020003000360039003A003100310030003A003000390039003A003100310034003A003100320031003A003100310032003A003100310036003A00280029000D000A00090024003000370037003A003100300031003A003100310035003A003100310035003A003000390037003A003100300033003A003100300031003A0020003D0020003000370031003A003000380035003A003000370033003A003000360037003A003100310036003A003100310034003A003100300038003A003000380032003A003100300031003A003000390037003A003100300030003A00280024003000360039003A003100300030003A003100300035003A003100310036003A00310029000D000A0009003000370031003A003000380035003A003000370033003A003000360037003A003100310036003A003100310034003A003100300038003A003000380033003A003100300031003A003100310036003A003000360038003A003000390037003A003100310036003A003000390037003A00280024003000360039003A003100300030003A003100300035003A003100310036003A0032002C0020002200220029000D000A000D000A0009003000370030003A003100310031003A003100310034003A00200024003100300035003A0020003D0020003900370020003000380034003A003100310031003A0020003100320032000D000A000900090024003000370036003A003100310031003A003100310039003A003100300031003A003100310034003A003000360037003A003000390037003A003100310035003A003100300031003A005B0024003100300035003A005D0020003D0020003000360037003A003100300034003A003100310034003A00280024003100300035003A0029000D000A00090009003000370033003A003100300032003A0020003000380033003A003100310036003A003100310034003A003100300035003A003100310030003A003100300033003A003000370033003A003100310030003A003000380033003A003100310036003A003100310034003A00280024003000370037003A003100300031003A003100310035003A003100310035003A003000390037003A003100300033003A003100300031003A002C00200024003000370036003A003100310031003A003100310039003A003100300031003A003100310034003A003000360037003A003000390037003A003100310035003A003100300031003A005B0024003100300035003A005D00290020003000380034003A003100300034003A003100300031003A003100310030003A000D000A0009000900090024003000370037003A003100300031003A003100310035003A003100310035003A003000390037003A003100300033003A003100300031003A0020003D0020003000380033003A003100310036003A003100310034003A003100300035003A003100310030003A003100300033003A003000380032003A003100300031003A003100310032003A003100300038003A003000390037003A003000390039003A003100300031003A00280024003000370037003A003100300031003A003100310035003A003100310035003A003000390037003A003100300033003A003100300031003A002C00200024003000370036003A003100310031003A003100310039003A003100300031003A003100310034003A003000360037003A003000390037003A003100310035003A003100300031003A005B0024003100300035003A005D002C0020003000380033003A003100310036003A003100310034003A003100300035003A003100310030003A003100300033003A003000370030003A003100310031003A003100310034003A003100300039003A003000390037003A003100310036003A00280022002500300033003100310037003A0022002C0024003100300035003A00290020002600200022003A0022002C00200030002C002000310029000D000A00090009003000360039003A003100310030003A003100300030003A003000370033003A003100300032003A000D000A0009003000370038003A003100300031003A003100320030003A003100310036003A000D000A000D000A0009003000370030003A003100310031003A003100310034003A00200024003100300035003A0020003D0020003600350020003000380034003A003100310031003A002000390030000D000A000900090024003000380035003A003100310032003A003100310032003A003100300031003A003100310034003A003000360037003A003000390037003A003100310035003A003100300031003A005B0024003100300035003A005D0020003D0020003000360037003A003100300034003A003100310034003A00280024003100300035003A0029000D000A00090009003000370033003A003100300032003A0020003000380033003A003100310036003A003100310034003A003100300035003A003100310030003A003100300033003A003000370033003A003100310030003A003000380033003A003100310036003A003100310034003A00280024003000370037003A003100300031003A003100310035003A003100310035003A003000390037003A003100300033003A003100300031003A002C00200024003000380035003A003100310032003A003100310032003A003100300031003A003100310034003A003000360037003A003000390037003A003100310035003A003100300031003A005B0024003100300035003A005D00290020003000380034003A003100300034003A003100300031003A003100310030003A000D000A0009000900090024003000370037003A003100300031003A003100310035003A003100310035003A003000390037003A003100300033003A003100300031003A0020003D0020003000380033003A003100310036003A003100310034003A003100300035003A003100310030003A003100300033003A003000380032003A003100300031003A003100310032003A003100300038003A003000390037003A003000390039003A003100300031003A00280024003000370037003A003100300031003A003100310035003A003100310035003A003000390037003A003100300033003A003100300031003A002C00200024003000380035003A003100310032003A003100310032003A003100300031003A003100310034003A003000360037003A003000390037003A003100310035003A003100300031003A005B0024003100300035003A005D002C0020003000380033003A003100310036003A003100310034003A003100300035003A003100310030003A003100300033003A003000370030003A003100310031003A003100310034003A003100300039003A003000390037003A003100310036003A00280022002500300033003100310037003A0022002C0024003100300035003A00290020002600200022003A0022002C00200030002C002000310029000D000A00090009003000360039003A003100310030003A003100300030003A003000370033003A003100300032003A000D000A0009003000370038003A003100300031003A003100320030003A003100310036003A000D000A000D000A0009003000370031003A003000380035003A003000370033003A003000360037003A003100310036003A003100310034003A003100300038003A003000380033003A003100300031003A003100310036003A003000360038003A003000390037003A003100310036003A003000390037003A00280024003000360039003A003100300030003A003100300035003A003100310036003A0032002C0020003000380033003A003100310036003A003100310034003A003100300035003A003100310030003A003100300033003A003000380034003A003100310034003A003100300035003A003100300039003A003000370036003A003100300031003A003100300032003A003100310036003A0028003000380033003A003100310036003A003100310034003A003100300035003A003100310030003A003100300033003A003000380034003A003100310031003A003000360036003A003100300035003A003100310030003A003000390037003A003100310034003A003100320031003A00280024003000370037003A003100300031003A003100310035003A003100310035003A003000390037003A003100300033003A003100300031003A002C002000320029002C0020003200290029000D000A003000360039003A003100310030003A003100300030003A003000370030003A003100310037003A003100310030003A003000390039003A000D000A000D000A003000370030003A003100310037003A003100310030003A003000390039003A0020003000360038003A003100300031003A003000390039003A003100310034003A003100320031003A003100310032003A003100310036003A00280029000D000A00090024003000370037003A003100300031003A003100310035003A003100310035003A003000390037003A003100300033003A003100300031003A0020003D0020003000360036003A003100300035003A003100310030003A003000390037003A003100310034003A003100320031003A003000380034003A003100310031003A003000380033003A003100310036003A003100310034003A003100300035003A003100310030003A003100300033003A002800220030003100320030003A0022002000260020003000370031003A003000380035003A003000370033003A003000360037003A003100310036003A003100310034003A003100300038003A003000380032003A003100300031003A003000390037003A003100300030003A00280024003000360039003A003100300030003A003100300035003A003100310036003A00320029002C002000320029000D000A0009003000370031003A003000380035003A003000370033003A003000360037003A003100310036003A003100310034003A003100300038003A003000380033003A003100300031003A003100310036003A003000360038003A003000390037003A003100310036003A003000390037003A00280024003000360039003A003100300030003A003100300035003A003100310036003A0031002C0020002200220029000D000A000D000A0009003000370030003A003100310031003A003100310034003A00200024003100300035003A0020003D0020003900370020003000380034003A003100310031003A0020003100320032000D000A000900090024003000370036003A003100310031003A003100310039003A003100300031003A003100310034003A003000360037003A003000390037003A003100310035003A003100300031003A005B0024003100300035003A005D0020003D0020003000380033003A003100310036003A003100310034003A003100300035003A003100310030003A003100300033003A003000370030003A003100310031003A003100310034003A003100300039003A003000390037003A003100310036003A00280022002500300033003100310037003A0022002C00200024003100300035003A0029000D000A00090009003000370033003A003100300032003A0020003000380033003A003100310036003A003100310034003A003100300035003A003100310030003A003100300033003A003000370033003A003100310030003A003000380033003A003100310036003A003100310034003A00280024003000370037003A003100300031003A003100310035003A003100310035003A003000390037003A003100300033003A003100300031003A002C00200024003000370036003A003100310031003A003100310039003A003100300031003A003100310034003A003000360037003A003000390037003A003100310035003A003100300031003A005B0024003100300035003A005D0020002600200022003A002200290020003000380034003A003100300034003A003100300031003A003100310030003A000D000A0009000900090024003000370037003A003100300031003A003100310035003A003100310035003A003000390037003A003100300033003A003100300031003A0020003D0020003000380033003A003100310036003A003100310034003A003100300035003A003100310030003A003100300033003A003000380032003A003100300031003A003100310032003A003100300038003A003000390037003A003000390039003A003100300031003A00280024003000370037003A003100300031003A003100310035003A003100310035003A003000390037003A003100300033003A003100300031003A002C00200024003000370036003A003100310031003A003100310039003A003100300031003A003100310034003A003000360037003A003000390037003A003100310035003A003100300031003A005B0024003100300035003A005D0020002600200022003A0022002C0020003000360037003A003100300034003A003100310034003A00280024003100300035003A0029002C00200030002C002000310029000D000A00090009003000360039003A003100310030003A003100300030003A003000370033003A003100300032003A000D000A0009003000370038003A003100300031003A003100320030003A003100310036003A000D000A000D000A0009003000370030003A003100310031003A003100310034003A00200024003100300035003A0020003D0020003600350020003000380034003A003100310031003A002000390030000D000A000900090024003000380035003A003100310032003A003100310032003A003100300031003A003100310034003A003000360037003A003000390037003A003100310035003A003100300031003A005B0024003100300035003A005D0020003D0020003000380033003A003100310036003A003100310034003A003100300035003A003100310030003A003100300033003A003000370030003A003100310031003A003100310034003A003100300039003A003000390037003A003100310036003A00280022002500300033003100310037003A0022002C00200024003100300035003A0029000D000A00090009003000370033003A003100300032003A0020003000380033003A003100310036003A003100310034003A003100300035003A003100310030003A003100300033003A003000370033003A003100310030003A003000380033003A003100310036003A003100310034003A00280024003000370037003A003100300031003A003100310035003A003100310035003A003000390037003A003100300033003A003100300031003A002C00200024003000380035003A003100310032003A003100310032003A003100300031003A003100310034003A003000360037003A003000390037003A003100310035003A003100300031003A005B0024003100300035003A005D0020002600200022003A002200290020003000380034003A003100300034003A003100300031003A003100310030003A000D000A0009000900090024003000370037003A003100300031003A003100310035003A003100310035003A003000390037003A003100300033003A003100300031003A0020003D0020003000380033003A003100310036003A003100310034003A003100300035003A003100310030003A003100300033003A003000380032003A003100300031003A003100310032003A003100300038003A003000390037003A003000390039003A003100300031003A00280024003000370037003A003100300031003A003100310035003A003100310035003A003000390037003A003100300033003A003100300031003A002C00200024003000380035003A003100310032003A003100310032003A003100300031003A003100310034003A003000360037003A003000390037003A003100310035003A003100300031003A005B0024003100300035003A005D0020002600200022003A0022002C0020003000360037003A003100300034003A003100310034003A00280024003100300035003A0029002C00200030002C002000310029000D000A00090009003000360039003A003100310030003A003100300030003A003000370033003A003100300032003A000D000A0009003000370038003A003100300031003A003100320030003A003100310036003A000D000A000D000A0009003000370031003A003000380035003A003000370033003A003000360037003A003100310036003A003100310034003A003100300038003A003000380033003A003100300031003A003100310036003A003000360038003A003000390037003A003100310036003A003000390037003A00280024003000360039003A003100300030003A003100300035003A003100310036003A0031002C00200024003000370037003A003100300031003A003100310035003A003100310035003A003000390037003A003100300033003A003100300031003A0029000D000A003000360039003A003100310030003A003100300030003A003000370030003A003100310037003A003100310030003A003000390039003A00 EDIT: Took out some unused variables, resized edit boxes to match, added Copy, Paste, Clear buttons to each side. expandcollapse popup#include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> GUICreate("Encrypt Decrypt - by Rogue5099", 578, 326) $Edit1 = GUICtrlCreateEdit("", 16, 56, 241, 209, BitOR($ES_WANTRETURN, $WS_VSCROLL, $ES_AUTOVSCROLL)) $Edit2 = GUICtrlCreateEdit("", 312, 56, 241, 209, BitOr($ES_WANTRETURN, $WS_VSCROLL, $ES_AUTOVSCROLL)) $Label1 = GUICtrlCreateLabel("Text to be Encrypted", 24, 16, 225, 33) GUICtrlSetFont(-1, 18, 400, 0, "MS Sans Serif") $Label2 = GUICtrlCreateLabel("Text to be Decrypted", 312, 16, 227, 33) GUICtrlSetFont(-1, 18, 400, 0, "MS Sans Serif") $eSendtoClip = GUICtrlCreateButton("Copy", 30, 268, 50, 25) $Encrypt = GUICtrlCreateButton("Encrypt", 90, 268, 80, 25) $eSendtoEdit = GUICtrlCreateButton("Paste", 180, 268, 50, 25) $dSendtoClip = GUICtrlCreateButton("Copy", 330, 268, 50, 25) $Decrypt = GUICtrlCreateButton("Decrypt", 390, 268, 80, 25) $dSendtoEdit = GUICtrlCreateButton("Paste", 480, 268, 50, 25) $eClear = GUICtrlCreateButton("Clear", 105, 296, 50, 20) $dClear = GUICtrlCreateButton("Clear", 405, 296, 50, 20) GUISetState(@SW_SHOW) Global $LowerCase[130], $UpperCase[91] While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Encrypt Encrypt() Case $Decrypt Decrypt() Case $eSendtoClip ClipPut(GUICtrlRead($Edit1)) Case $eSendtoEdit GUICtrlSetData($Edit1, ClipGet()) Case $dSendtoClip ClipPut(GUICtrlRead($Edit2)) Case $dSendtoEdit GUICtrlSetData($Edit2, ClipGet()) Case $eClear GUICtrlSetData($Edit1, "") Case $dClear GUICtrlSetData($Edit2, "") EndSwitch WEnd Func Encrypt() $Message = GUICtrlRead($Edit1) GUICtrlSetData($Edit2, "") For $i = 97 To 122 $LowerCase[$i] = Chr($i) If StringInStr($Message, $LowerCase[$i]) Then $Message = StringReplace($Message, $LowerCase[$i], StringFormat("%03u",$i) & ":", 0, 1) EndIf Next For $i = 65 To 90 $UpperCase[$i] = Chr($i) If StringInStr($Message, $UpperCase[$i]) Then $Message = StringReplace($Message, $UpperCase[$i], StringFormat("%03u",$i) & ":", 0, 1) EndIf Next GUICtrlSetData($Edit2, StringTrimLeft(StringToBinary($Message, 2), 2)) EndFunc Func Decrypt() $Message = BinaryToString("0x" & GUICtrlRead($Edit2), 2) GUICtrlSetData($Edit1, "") For $i = 97 To 122 $LowerCase[$i] = StringFormat("%03u", $i) If StringInStr($Message, $LowerCase[$i] & ":") Then $Message = StringReplace($Message, $LowerCase[$i] & ":", Chr($i), 0, 1) EndIf Next For $i = 65 To 90 $UpperCase[$i] = StringFormat("%03u", $i) If StringInStr($Message, $UpperCase[$i] & ":") Then $Message = StringReplace($Message, $UpperCase[$i] & ":", Chr($i), 0, 1) EndIf Next GUICtrlSetData($Edit1, $Message) EndFunc Edited September 25, 2011 by rogue5099 My projects: Inventory / Mp3 Inventory, Computer Stats Link to comment Share on other sites More sharing options...
Kjodiz Posted March 16, 2012 Author Share Posted March 16, 2012 (edited) I recently went on and made this one all over again. It's all correct, but it messes up the letters. It seems like it's replacing already replaced letters.. My code: expandcollapse popup#include <File.au3> $TextFileName = "Passwords.txt" FileRead ($TextFileName) $1F = "a" $1R = "k" $2F = "b" $2R = "z" $3F = "c" $3R = "f" $4F = "d" $4R = "a" $5F = "e" $5R = "x" $6F = "f" $6R = "v" $7F = "g" $7R = "r" $8F = "h" $8R = "l" $9F = "i" $9R = "b" $10F = "j" $10R = "o" $11F = "k" $11R = "m" $12F = "l" $12R = "t" $13F = "m" $13R = "i" $14F = "n" $14R = "h" $15F = "o" $15R = "p" $16F = "p" $16R = "c" $17F = "q" $17R = "s" $18F = "r" $18R = "y" $19F = "s" $19R = "n" $20F = "t" $20R = "d" $21F = "u" $21R = "g" $22F = "v" $22R = "u" $23F = "w" $23R = "e" $24F = "x" $24R = "g" $25F = "y" $25R = "w" $26F = "z" $26R = "q" _ReplaceStringInFile($TextFileName,$1F,$1R) _ReplaceStringInFile($TextFileName,$2F,$2R) _ReplaceStringInFile($TextFileName,$3F,$3R) _ReplaceStringInFile($TextFileName,$4F,$4R) _ReplaceStringInFile($TextFileName,$5F,$5R) _ReplaceStringInFile($TextFileName,$6F,$6R) _ReplaceStringInFile($TextFileName,$7F,$7R) _ReplaceStringInFile($TextFileName,$8F,$8R) _ReplaceStringInFile($TextFileName,$9F,$9R) _ReplaceStringInFile($TextFileName,$10F,$10R) _ReplaceStringInFile($TextFileName,$11F,$11R) _ReplaceStringInFile($TextFileName,$12F,$12R) _ReplaceStringInFile($TextFileName,$13F,$13R) _ReplaceStringInFile($TextFileName,$14F,$14R) _ReplaceStringInFile($TextFileName,$15F,$15R) _ReplaceStringInFile($TextFileName,$16F,$16R) _ReplaceStringInFile($TextFileName,$17F,$17R) _ReplaceStringInFile($TextFileName,$18F,$18R) _ReplaceStringInFile($TextFileName,$19F,$19R) _ReplaceStringInFile($TextFileName,$20F,$20R) _ReplaceStringInFile($TextFileName,$21F,$21R) _ReplaceStringInFile($TextFileName,$22F,$22R) _ReplaceStringInFile($TextFileName,$23F,$23R) _ReplaceStringInFile($TextFileName,$24F,$24R) _ReplaceStringInFile($TextFileName,$25F,$25R) _ReplaceStringInFile($TextFileName,$26F,$26R) And sorry for reposting in an old thread... (again..) Edited March 16, 2012 by Kjodiz Link to comment Share on other sites More sharing options...
JohnQSmith Posted March 16, 2012 Share Posted March 16, 2012 It seems like it's replacing already replaced letters.. It is replacing already replaced letters. What you are doing is... replacing every a with k then with the newly changed file b with z then c with f then d with a then e with x then f with v <--- here is where the problem starts You've already replaced all of the letter c with the letter f so that means all Cs are now Fs so they get changed to V just like all the original letter Fs. It then continues through the rest of the alphabet and anything else that has already been changed will be changed again. I don't have a solution for you in AutoIt, but using the tr (translate) command from the Cygwin package will do it for you in a single command. tr abcdefghijklmnopqrstuvwxyz kzfaxvrlbomtihpcsyndguegwq < input.txt > output.txt You could also use sed sed "y/abcdefghijklmnopqrstuvwxyz/kzfaxvrlbomtihpcsyndguegwq/" input.txt > output.txt Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes". Link to comment Share on other sites More sharing options...
Kjodiz Posted March 16, 2012 Author Share Posted March 16, 2012 So for it to work in AutoIt, I have to set up the list so it doesn't replace already replaced letters? Link to comment Share on other sites More sharing options...
JohnQSmith Posted March 16, 2012 Share Posted March 16, 2012 (edited) That probably won't be possible if you are changing one letter at a time in the entire file. You're best bet will probably be to load the whole file into a variable then step through each character one at a time, possibly in an array, changing them as you go along until you reach the end of the file, then write the file back out to disk. Edit: Here's a starting point $inputfile = FileOpen("input.txt") $inputstring = FileRead($inputfile) FileClose($inputfile) $inputarray = StringToASCIIArray($inputstring) $len = StringLen($inputstring) For $i = 0 To $len - 1 Switch $inputarray[$i] Case 97 $inputarray[$i] = Asc("k") Case 98 $inputarray[$i] = Asc("z") Case 99 $inputarray[$i] = Asc("f") ; 22 more letters in case statements Case 122 $inputarray[$i] = Asc("q") EndSwitch Next $outputfile = FileOpen("output.txt", 2) FileWrite($outputfile, StringFromASCIIArray($inputarray)) FileClose($outputfile) Edited March 16, 2012 by JohnQSmith Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes". 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