Xors Binary File Encyption/Decryption [Solved]

Blitz3D Forums/Blitz3D Programming/Xors Binary File Encyption/Decryption [Solved]

RustyKristi(Posted 2016) [#1]
I was wondering where I can find a snippet where you can encrypt/decrypt a binary file using XOR?

I found only the example and do you think this is good enough?

http://www.blitzbasic.com/b3ddocs/command.php?name=Xor


Matty(Posted 2016) [#2]
;Simple xor encryption with crappy key
;swap the input and output files to see it in action...(decryption is encrpytion in reverse)
seedrnd 1 ;this is your key...(actually the key is the same length as the file and is determined as a random sequence by this seed)
infile = readfile("yourinputfile.txt")
outfile = writefile("youroutputfile.txt")
while(not(eof(infile)))
    writebyte outfile,readbyte(infile) xor rand(0,255)
wend 
closefile outfile
closefile infile
end



RustyKristi(Posted 2016) [#3]
Thanks Matty, works great. solved :)


Yue(Posted 2016) [#4]
@Matty
Thanks You. :)


dna(Posted 2017) [#5]
** Sorry Wrong Thread **