[bb] Simple Encrypter/Decrypter by Rob Farley [ 1+ years ago ]

Started by BlitzBot, June 29, 2017, 00:28:42

Previous topic - Next topic

BlitzBot

Title : Simple Encrypter/Decrypter
Author : Rob Farley
Posted : 1+ years ago

Description : Okay, this isn't high security or anything like that, however, if you've got files that place objects, save high scores etc and you don't want people monkeying around with them this should be enough to put someone off.

Simply set the input file and output file and it does the rest.

have fun!


Code :
Code (blitzbasic) Select
; ===================================================================================================
; Simple encrypter/decrypter
; 2003 Mental Illusion
; http://www.mentalillusion.co.uk
; rob@mentalillusion.co.uk
; ===================================================================================================


; I know this isn't high security or anything, but it's enough to make people not bother!


; Usage
;        encrypt(Input file, output file, random seed)
;        decrypt(Input file, output file)


encrypt("test.txt","encrypted.txt",1)

decrypt("encrypted.txt","decrypted.txt")

End


Function encrypt(input_file$,output_file$,seed)
SeedRnd seed
filein = ReadFile(input_file)
fileout = WriteFile(output_file)
WriteString (fileout,seed)
While Not Eof(filein)
temp$=ReadLine(filein)
enc$=""
For n=1 To Len(temp$)
t=Asc(Mid(temp,n,1))
t=t+Rand(1,Rand(1,128))
If t>255 Then t=t-255
enc=enc+Chr$(t)
Next
WriteLine(fileout,enc$)
Wend
CloseFile (filein)
CloseFile(fileout)
End Function


Function decrypt(input_file$,output_file$)
filein = ReadFile(input_file)
fileout = WriteFile(output_file)
seed=ReadString(filein)
SeedRnd seed
While Not Eof(filein)
temp$=ReadLine(filein)
enc$=""
For n=1 To Len(temp$)
t=Asc(Mid(temp,n,1))
t=t-Rand(1,Rand(1,128))
If t<0 Then t=t+255
enc=enc+Chr$(t)
Next
WriteLine(fileout,enc$)
Wend
CloseFile (filein)
CloseFile(fileout)
End Function


Comments :


Blitz123(Posted 1+ years ago)

 This could also be used for secret programing comunications.....