zeroZshadow Posted July 4, 2005 Share Posted July 4, 2005 is it FINEALY possible to convert a file to hex and revers?? this way i can stream my files over the net. i started a topic like this before, but then file handeling like this wasn't possible, but is it now?? please reply *If u thought life couldn't get worse, u meet me *<guy> What would you give my little sister to unzip ?<friend> 10 bucks<guy> No, i mean like Winzip... Link to comment Share on other sites More sharing options...
zeroZshadow Posted July 4, 2005 Author Share Posted July 4, 2005 doesn't enyone knows the anwser?? *If u thought life couldn't get worse, u meet me *<guy> What would you give my little sister to unzip ?<friend> 10 bucks<guy> No, i mean like Winzip... Link to comment Share on other sites More sharing options...
MSLx Fanboy Posted July 4, 2005 Share Posted July 4, 2005 (edited) #include<string.au3> FileWrite("file2.txt", _StringToHex(FileRead("file.txt", FileGetSize("file.txt")))) FileWrite("file3.txt", _HexToString(FileRead("file2.txt", FileGetSize("file2.txt")))) Probably not what you're looking for but... Edit...Go with Larry's, that works for binary files... Edited July 4, 2005 by MSLx Fanboy Writing AutoIt scripts since _DateAdd("d", -2, _NowCalcDate()) Link to comment Share on other sites More sharing options...
zeroZshadow Posted July 4, 2005 Author Share Posted July 4, 2005 mlx that doesn't work and THANKS LARRY!!! i'll try to speed it up for ya *If u thought life couldn't get worse, u meet me *<guy> What would you give my little sister to unzip ?<friend> 10 bucks<guy> No, i mean like Winzip... Link to comment Share on other sites More sharing options...
zeroZshadow Posted July 7, 2005 Author Share Posted July 7, 2005 Dear Larry, if ur reading this... else ANYBODY OUT THERE~!! can somebody PLEASE fix the eof bug with files other then text files... its really anoying. because i finished my file to ascii and backwards completely, but the problem is that it only takes a little part of the file because it finds a NOT EXISTING EOF in the file... ...i hate that bug... well here is the code so far, have fun. expandcollapse popup#include <file.au3> Global $asciires = "" Global $chrres = "" Global $read = "" _ascii() _file() Func _ascii() ConsoleWrite("Converting to Ascii"&@LF) $file = FileOpen("test.jpeg",0) $l = 1 while 1 $lineread = FileReadLine ($file,$l) if @error = -1 then exitloop if @error = 1 then msgbox(0,"Error","File Could not be opened") Exit EndIf $linecharcount = StringLen ($lineread) for $ll = 1 to $linecharcount $char = StringMid ($lineread,$ll,1) $result = Asc($char) $asciires = $asciires& "|" & $result Next $l = $l + 1 Wend FileWrite("Test.asc",$asciires) fileclose($file) ConsoleWrite("Done converting"&@CRLF) EndFunc Func _file() ConsoleWrite("Converting to File"&@LF) if NOT _FileReadToArray(@scriptdir&"\Test.asc",$read) then msgbox(0,"ERROR","An error has found while opening the file. Error: "&@error) Exit EndIf $asciiread = stringsplit($read[1],"|") for $l = 1 to $asciiread[0] $result = chr($asciiread[$l]) $chrres = $chrres & $result Next filedelete("Test.asc") FileWrite("result.jpeg",$chrres) ConsoleWrite("Done converting"&@CRLF) EndFunc *If u thought life couldn't get worse, u meet me *<guy> What would you give my little sister to unzip ?<friend> 10 bucks<guy> No, i mean like Winzip... Link to comment Share on other sites More sharing options...
jamesband Posted July 7, 2005 Share Posted July 7, 2005 This is not really a BUG... You are converting a jpeg. Jpegs should be treated as binary files. You need to use AutoIT beta and Larry's Binary UDF. Also, you might want to use Hex instead. Hex representation of characters will always be 2 digits so no delimiters are needed. Your current code would, if it worked on the entire file, create a new file up to 4 times the original size! With hex you would only double the size.JamesBandDear Larry, if ur reading this... else ANYBODY OUT THERE~!!can somebody PLEASE fix the eof bug with files other then text files...its really anoying.because i finished my file to ascii and backwards completely, but the problem is that it only takes a little part of the file because it finds a NOT EXISTING EOF in the file......i hate that bug...well here is the code so far, have fun.expandcollapse popup#include <file.au3> Global $asciires = "" Global $chrres = "" Global $read = "" _ascii() _file() Func _ascii() ConsoleWrite("Converting to Ascii"&@LF) $file = FileOpen("test.jpeg",0) $l = 1 while 1 $lineread = FileReadLine ($file,$l) if @error = -1 then exitloop if @error = 1 then msgbox(0,"Error","File Could not be opened") Exit EndIf $linecharcount = StringLen ($lineread) for $ll = 1 to $linecharcount $char = StringMid ($lineread,$ll,1) $result = Asc($char) $asciires = $asciires& "|" & $result Next $l = $l + 1 Wend FileWrite("Test.asc",$asciires) fileclose($file) ConsoleWrite("Done converting"&@CRLF) EndFunc Func _file() ConsoleWrite("Converting to File"&@LF) if NOT _FileReadToArray(@scriptdir&"\Test.asc",$read) then msgbox(0,"ERROR","An error has found while opening the file. Error: "&@error) Exit EndIf $asciiread = stringsplit($read[1],"|") for $l = 1 to $asciiread[0] $result = chr($asciiread[$l]) $chrres = $chrres & $result Next filedelete("Test.asc") FileWrite("result.jpeg",$chrres) ConsoleWrite("Done converting"&@CRLF) EndFunc<{POST_SNAPBACK}> Link to comment Share on other sites More sharing options...
zeroZshadow Posted July 27, 2005 Author Share Posted July 27, 2005 lol, i think i can better find a way to directly transfer the bineary over the net then *If u thought life couldn't get worse, u meet me *<guy> What would you give my little sister to unzip ?<friend> 10 bucks<guy> No, i mean like Winzip... Link to comment Share on other sites More sharing options...
blindwig Posted July 27, 2005 Share Posted July 27, 2005 (edited) The best way to use binary files I've found is to convert them to Base64 text and send them as text files, then decode them back to binary on the other side.AutoIt cannot do the conversion natively. I wrote a Base64 Encoding and Decoding UDF, but the Decoding one doesn't work because it still cannot write char #0 to a file.So my advice is to use an external decoder.Here is an easy-to-use open-sourced command-line driven encoder/decoder:http://www.fourmilab.ch/webtools/base64/ Edited July 27, 2005 by blindwig My UDF Threads:Pseudo-Hash: Binary Trees, Flat TablesFiles: Filter by Attribute, Tree List, Recursive Find, Recursive Folders Size, exported to XMLArrays: Nested, Pull Common Elements, Display 2dSystem: Expand Environment Strings, List Drives, List USB DrivesMisc: Multi-Layer Progress Bars, Binary FlagsStrings: Find Char(s) in String, Find String in SetOther UDF Threads I Participated:Base64 Conversions Link to comment Share on other sites More sharing options...
zeroZshadow Posted July 27, 2005 Author Share Posted July 27, 2005 THAT WORKS GREAT!!! man i love you , wel not really it can even be handeled by autoit after encoding man i like you :D:D its ALLOT faster then larry's way *If u thought life couldn't get worse, u meet me *<guy> What would you give my little sister to unzip ?<friend> 10 bucks<guy> No, i mean like Winzip... 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