06-22-2006, 08:55 PM
Yetifoot is right - I didn't read the code properly and so I didn't notice that you were modifying each character with a different value. That is more secure than plain XOR - the cracker can't simply look for patterns as I described above. Still, don't trust your banking numbers to it. :wink:
Here's an encryption method that is, in principle, unbreakable, because there is no pattern or uniform algorithm whatsoever to work with. It's simple: there are two files, infile and passfile. They must be EXACTLY the same size. Character 0 in infile is XORed with character 0 in passfile. Character 1 in infile is XORed with character 1 in passfile, character 2 in infile is XORed with character 2 in passfile, and so on. The results are stored in outfile.
red_marvin originally suggested this method to me.
Here's an encryption method that is, in principle, unbreakable, because there is no pattern or uniform algorithm whatsoever to work with. It's simple: there are two files, infile and passfile. They must be EXACTLY the same size. Character 0 in infile is XORed with character 0 in passfile. Character 1 in infile is XORed with character 1 in passfile, character 2 in infile is XORed with character 2 in passfile, and so on. The results are stored in outfile.
Code:
#define infile "infile.txt"
#define passfile "passfile.txt"
#define outfile "outfile.enc"
dim as integer ifHandle,pfHandle,ofHandle,fpos
dim as ubyte ifTemp,passTemp
ifHandle=freefile
pfHandle=ifHandle+1
ofHandle=pfHandle+1
open infile for binary as #ifHandle
open passfile for binary as #pfHandle
open outfile for binary as #ofHandle
if lof(ifHandle)<>lof(pfHandle) then
print "Error: different file lengths."
sleep
end
end if
do
get #ifHandle,,ifTemp
get #pfHandle,,passTemp
put #ofHandle,,chr$(ifTemp xor passTemp)
fpos+=1
if fpos>=lof(ifHandle) then exit do
loop
print "Done."
sleep
close
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
--------------------------------------
Freebasic is like QB, except it doesn't suck.