Save RC4 Encryption Load RC4 Decrypt
BlitzMax Forums/BlitzMax Programming/Save RC4 Encryption Load RC4 Decrypt
| ||
Hi All - I'm using the RC4 Encryption in the following link http://www.blitzbasic.com/codearcs/codearcs.php?code=1711 I'm unable to load and decrypt was I've previously encrypted, could someone help me figure out the following code? It has something to do with the contents of game.txt game.txt blitzcode.bmx [codebox] Strict Local key:String = "09832hvb3@#)Fccenw238hr#@NO#@N#@dq" Local file:TStream = ReadFile("game.txt") Local data:String While Not Eof(file) data:+ReadLine(file) + "~n" Wend CloseStream(file) Print data Local encrypted:String = RC4(data,key) Print encrypted file = WriteFile("test.txt") WriteLine(file,encrypted) CloseStream(file) file = ReadFile("test.txt") Local data2:String Local count:Int |
| ||
Ran out of room... blitzcode.bmx |
| ||
Hello, if you replace file = ReadFile("test.txt") Local data2:String Local count:Int While Not Eof(file) data2:+ReadLine(file) + "~n" count:+1 Wend ...with this file = ReadFile("test.txt") Local count:Int Local data2:String = LoadText(file) ...it seems to work. -Henri |
| ||
Thanks! Perfect |
| ||
What's the difference between LoadText and LoadString functions? |
| ||
LoadText() is a little more complicated function and takes into account the UTF-format that the file was saved. LoadString() is basically same as LoadByteArray() then return string from loaded byte array (turn bytes into characters). So LoadString() is faster, but LoadText() involve more checking. Both might work. -Henri |