John117 Posted November 20, 2007 Share Posted November 20, 2007 I am working on the following code. It is intended to decrypt a txt file line and add it to an array. -not working Can this be done? I just need the txt to stay encrypted, but the code to pull the info with the correct decryption . . . ; Read file into an array _FileReadToArray($sFile, _StringEncrypt(0,$avFile, "12345", "1")) If @error Then MsgBox(16, "Error", "Error opening file: " & $sFile) Exit EndIf Link to comment Share on other sites More sharing options...
DW1 Posted November 20, 2007 Share Posted November 20, 2007 Hope this gets you on your way. If you have any questions, just ask. If I misunderstood your question, please let me know where I went wrong. #include <String.au3> #include <File.au3> #include <Array.au3> Dim $filecontents Dim $decryptedfile[1] $sFile = "C:\testenc.txt" _FileReadToArray($sFile, $filecontents) If @error Then MsgBox(16, "Error", "Error opening file: " & $sFile) Exit EndIf MsgBox(0,"test", $filecontents[0] ) $decryptedfile[0] = $filecontents[0] For $avar = 1 to $filecontents[0] ReDim $decryptedfile[$avar + 1] $decryptedfile[$avar] = _StringEncrypt(0, $filecontents[$avar], "12345") Next _ArrayDisplay( $decryptedfile, "Decrypted File Contents In Array" ) AutoIt3 Online Help Link to comment Share on other sites More sharing options...
PsaltyDS Posted November 20, 2007 Share Posted November 20, 2007 Demo of encrypt/decrypt from/to and array: #include <array.au3> #include <string.au3> Global $sFile = "C:\Temp\Test.txt" Global $avArray[10] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] Global $sPasswd = "12345" Global $hFile = FileOpen($sFile, 2) ; 2 = overwrite FileWrite($hFile, _StringEncrypt(1, _ArrayToString($avArray, Chr(01)), $sPasswd, 1)) FileClose($hFile) Run("notepad.exe " & $sFile) MsgBox(32, "Continue", "Ready to decrypt?") Global $avRead = StringSplit(_StringEncrypt(0, FileRead($sFile), $sPasswd, 1), Chr(01)) _ArrayDisplay($avRead, "Debug: $avRead") 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...
John117 Posted November 20, 2007 Author Share Posted November 20, 2007 (edited) I had hoped to beet you P Working on one of your posts. #include <file.au3> #include <guiconstants.au3> #include <string.au3> ; Each line of file is "User Name, Password" Global $sFile = "D:\Autoit Help\test.txt" Global $avFile, $sPasswd = "<not found>" ; Get user name to search for $sUser = InputBox("User Data", "Enter user name:") If @error Then Exit ; Read file into an array _FileReadToArray($sFile, $avFile) If @error Then MsgBox(16, "Error", "Error opening file: " & $sFile) Exit EndIf ; Search array for user name and get password For $i = 1 To $avFile[0] ;The Below line decrypts at level "1" using "12345" as password. "1" Being lowest, "10" being highest. $Temp = _StringEncrypt(0,$avFile[$i], "12345", "1") If StringLeft($Temp, StringLen($sUser) + 1) = $sUser & "," Then $sPasswd = StringStripWS(StringMid($Temp, StringInStr($Temp, ",") + 1), 8) ExitLoop EndIf Next ; Display results MsgBox(64, "Results", "User: " & $sUser & @CRLF & "Passwd: " & $sPasswd) Edited November 20, 2007 by Hatcheda Link to comment Share on other sites More sharing options...
DW1 Posted November 20, 2007 Share Posted November 20, 2007 I win AutoIt3 Online Help Link to comment Share on other sites More sharing options...
John117 Posted November 20, 2007 Author Share Posted November 20, 2007 Hope this gets you on your way. If you have any questions, just ask. If I misunderstood your question, please let me know where I went wrong.Hey, I'll still study it up, see what I can learn from it! Thanks always! 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