Encrypting files
Blitz3D Forums/Blitz3D Programming/Encrypting files
| ||
Hi, EDIT : I now wrote my own encryption, it's in the code archives, here : http://www.blitzbasic.com/codearcs/codearcs.php?code=1264 I want to encrypt/decrypt my savegame files (created with a mix of writestring, writeint and writefloat). I tried using this : http://www.blitzbasic.com/codearcs/codearcs.php?code=604 But it doesn't seem to work. I have three problems with it : - The seed that is the encryption key is stored in the save-file, which is not very secure (that's not too bad, most users won't figure out how to decrypt it anyway) - If a different computer uses the seeds differently, you can't exchange the savegame to that computer - But the worst part : sometimes, when decrypting, only a part of the file gets decrypted, and the rest is still scrambled - so it doesn't read it correctly (I could upload some examples if necessary) Does anyone have a fix for this, or an alternative? I could try making my own, but if anyone has something for this already, that would be easier, off course :) Thanks. |
| ||
Rob wrote that about a year ago. I never had any problems with it but I wasn't trying to encrypt a large file... just generate an encrypted sig to register my program. So it could be file size that gets you. Without seeing the source code I can only say loop 'till EOF and add characters at the EOF to make it even... Probably that muddys the issue. I am really good at muddying the issue! -RZ |
| ||
I think the problem may be that the encryption reads it line by line, and encrypts the line - bu in the new encrypted line, it could have introduced new newline characters by accident. These newline characters are not decrypted as they should, because the decryption also reads line by lines, and doesn't see the difference between these new newlines and the ones that were supposed to be newlines in the original file. I could be wrong, but it's my best guess. Maybe adding the lines of the file to one big string, and using that for encryption/decryption would work better. Edit : here's an example of what I mean : This could be the input line 1 : content of line1 line 2 : content of line2 line 3 : content of line3 But encrypting could lead to : line 1 : encrypted line1 line 2 : encrypted line2 - part 1 line 3 : encrypted line2 - part 2 line 4 : encrypted line3 now decrypting would read each line seperately and would lead to : line 1 : content of line1 line 2 : part of the content of line2 line 3 : part of the content of line2 line 4 : content of line3 Then again, I could be wrong :) |
| ||
Okay, I just wrote my own encryption, and it seems to work fine. I put it in the code archives if anyone wants it. http://www.blitzbasic.com/codearcs/codearcs.php?code=1264 Let me know what you think. |
| ||
Cool beans! |