mrmacadamia Posted January 19, 2010 Posted January 19, 2010 I don't know if this is because of my computer or a bug? I use the sample from the help file and the script keep reading blank eventhough it set @error to -1. $file = FileOpen("test.txt", 0) ; Check if file opened for reading OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf ; Read in 1 character at a time until the EOF is reached While 1 $chars = FileRead($file, 1) If @error = -1 Then ExitLoop MsgBox(0, "Char read:", $chars) Wend FileClose($file)
mrmacadamia Posted January 19, 2010 Author Posted January 19, 2010 On 1/19/2010 at 3:21 AM, 'Thanubis said: It works fine here. What is in your "test.txt" file?Hurm, strange. I just put a random word file.I tested it with random short, long or even single words.Nothing specific in the txt file, just want to know if it's a bug or just my computer.Recently, _StringEncrypt() also doesn't work fine for me.I don't know why is this happening to me.
PsaltyDS Posted January 19, 2010 Posted January 19, 2010 On 1/19/2010 at 3:57 AM, 'mrmacadamia said: Hurm, strange. I just put a random word file.I tested it with random short, long or even single words.Nothing specific in the txt file, just want to know if it's a bug or just my computer.You haven't provided a way to duplicate your symptoms. Quote Recently, _StringEncrypt() also doesn't work fine for me.The _StringEncrypt() function may have a sensitivity to certain code pages being used. Do you have a foreign language pack loaded? 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
MvGulik Posted January 19, 2010 Posted January 19, 2010 (edited) whatever Edited February 7, 2011 by MvGulik "Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions.""The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014) "Believing what you know ain't so" ... Knock Knock ...
mrmacadamia Posted January 19, 2010 Author Posted January 19, 2010 On 1/19/2010 at 4:05 AM, 'PsaltyDS said: You haven't provided a way to duplicate your symptoms.The _StringEncrypt() function may have a sensitivity to certain code pages being used. Do you have a foreign language pack loaded?yup..since i play around autoit with japs windows xp, i think this could be the reason.Other than that, when I use FileWrite() function, I always got unrecognized character.Anyway, I don't know. Maybe if I had english ver of windows xp laying around, I could test on it.By the way, you guys are awesome! thanks for the help.
MvGulik Posted January 19, 2010 Posted January 19, 2010 (edited) whatever Edited February 7, 2011 by MvGulik "Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions.""The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014) "Believing what you know ain't so" ... Knock Knock ...
mrmacadamia Posted February 1, 2010 Author Posted February 1, 2010 (edited) On 1/19/2010 at 4:05 AM, 'PsaltyDS said: You haven't provided a way to duplicate your symptoms. The _StringEncrypt() function may have a sensitivity to certain code pages being used. Do you have a foreign language pack loaded? I thought I've solved my problem. but still not. So, I come back. How do you unload the language pack? Well this the code I was playing around. I thought by using crypt.au3, I would have solved my problem, but still it didn't decrypt properly. The problem is that when I try with "ConsoleWrite($vall2)" , it did decrypt properly. But, when i try using with "ConsoleWrite($vall2 & @CRLF & $vall2)" or "msgbox(0, "", $vall2) it gives me the weird number, although the variable still the same. expandcollapse popup#include <Crypt.au3> Global $myDll = @ScriptDir & "\encryptdata.dll" Global $IniSection = Encrypt("iniSectionName") Global $SupEncKey = "aBcDeFg" Global $Mac = StringUpper (StringReplace (_GetMAC(),":","") & StringRight ( Hex(@YEAR),1)) IniWrite ($myDLL,$IniSection,Encrypt("GeneratedMac"),Encrypt($Mac)) $vall2 = Decrypt(IniRead ($myDll,$IniSection,Encrypt("GeneratedMac"),"Not Found")) ConsoleWrite($vall2) ConsoleWrite($vall2 & @CRLF & $vall2) Msgbox(0,"",$vall2) Func Encrypt($string) _Crypt_Startup() Local $hKey=_Crypt_DeriveKey("aBcDeFg", $CALG_RC4) Return _Crypt_EncryptData($string, $SupEncKey, $CALG_USERKEY) _Crypt_DestroyKey($hKey) _Crypt_Shutdown() EndFunc Func Decrypt($string) _Crypt_Startup() Local $hKey=_Crypt_DeriveKey("aBcDeFg", $CALG_RC4) Return _Crypt_DecryptData($string, $SupEncKey, $CALG_USERKEY) _Crypt_DestroyKey($hKey) _Crypt_Shutdown() EndFunc Func _GetMAC($getmacindex = 1);thanks to ChrisL for this function $ipHandle = Run(@ComSpec & ' /c ipconfig /all', '', @SW_HIDE, 2) $read = "" Do $read &= StdoutRead($ipHandle) Until @error $read = StringStripWS($read,7) $macdashed = StringRegExp( $read , '([0-9A-F]{2}-[0-9A-F]{2}-[0-9A-F]{2}-[0-9A-F]{2}-[0-9A-F]{2}-[0-9A-F]{2})', 3) If Not IsArray($macdashed) Then Return 0 If $getmacindex < 1 Then Return 0 If $getmacindex > UBound($macdashed) Or $getmacindex = -1 Then $getmacindex = UBound($macdashed) $macnosemicolon = StringReplace($macdashed[$getmacindex - 1], '-', ':', 0) Return $macnosemicolon EndFunc;==>_GetMAC Edited February 1, 2010 by mrmacadamia
mrmacadamia Posted February 1, 2010 Author Posted February 1, 2010 Hmm...interesting result I get when I change my system language to "English". but still doesn't decrypt properly which is giving me different result using the code above. I got different decrypt result which is much shorter(?) i guess.
mrmacadamia Posted February 1, 2010 Author Posted February 1, 2010 On 2/1/2010 at 5:25 AM, 'mrmacadamia said: Hmm...interesting result I get when I change my system language to "English". but still doesn't decrypt properly which is giving me different result using the code above.I got different decrypt result which is much shorter(?) i guess.Opsssss...I'm sorry. I think I've found the solution.I should use "BinaryToString($vall2)".But anyway, I'm still wondering why if I use "ConsoleWrite($vall2 & @CRLF & $vall2)" gives me different value than "ConsoleWrite($vall2)"
KJohn Posted February 1, 2010 Posted February 1, 2010 Replace this in your code: If @error = -1 Then ExitLoop with this: If @error Then ExitLoop and see what happens.
mrmacadamia Posted February 1, 2010 Author Posted February 1, 2010 (edited) On 2/1/2010 at 8:25 AM, 'Koshy John said: Replace this in your code: If @error = -1 Then ExitLoop with this: If @error Then ExitLoop and see what happens. I can't see any code that you mentioned in my script. edit... Ahh...the first one above. sorry. Edited February 1, 2010 by mrmacadamia
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