Ooops
October 28, 2020, 06:10:31 AM

Author Topic: [bb] Simple Encrypter/Decrypter by Rob Farley [ 1+ years ago ]  (Read 1162 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
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
  1. ; ===================================================================================================
  2. ; Simple encrypter/decrypter
  3. ; 2003 Mental Illusion
  4. ; http://www.mentalillusion.co.uk
  5. ; rob@mentalillusion.co.uk
  6. ; ===================================================================================================
  7.  
  8.  
  9. ; I know this isn't high security or anything, but it's enough to make people not bother!
  10.  
  11.  
  12. ; Usage
  13. ;        encrypt(Input file, output file, random seed)
  14. ;        decrypt(Input file, output file)
  15.  
  16.  
  17. encrypt("test.txt","encrypted.txt",1)
  18.  
  19. decrypt("encrypted.txt","decrypted.txt")
  20.  
  21. End
  22.  
  23.  
  24. Function encrypt(input_file$,output_file$,seed)
  25. SeedRnd seed
  26. filein = ReadFile(input_file)
  27. fileout = WriteFile(output_file)
  28. WriteString (fileout,seed)
  29. While Not Eof(filein)
  30.         temp$=ReadLine(filein)
  31.         enc$=""
  32.         For n=1 To Len(temp$)
  33.                 t=Asc(Mid(temp,n,1))
  34.                 t=t+Rand(1,Rand(1,128))
  35.                 If t>255 Then t=t-255
  36.                 enc=enc+Chr$(t)
  37.                 Next
  38.         WriteLine(fileout,enc$)
  39.         Wend
  40. CloseFile (filein)
  41. CloseFile(fileout)
  42. End Function
  43.  
  44.  
  45. Function decrypt(input_file$,output_file$)
  46. filein = ReadFile(input_file)
  47. fileout = WriteFile(output_file)
  48. seed=ReadString(filein)
  49. SeedRnd seed
  50. While Not Eof(filein)
  51.         temp$=ReadLine(filein)
  52.         enc$=""
  53.         For n=1 To Len(temp$)
  54.                 t=Asc(Mid(temp,n,1))
  55.                 t=t-Rand(1,Rand(1,128))
  56.                 If t<0 Then t=t+255
  57.                 enc=enc+Chr$(t)
  58.                 Next
  59.         WriteLine(fileout,enc$)
  60.         Wend
  61. CloseFile (filein)
  62. CloseFile(fileout)
  63. End Function


Comments :


Blitz123(Posted 1+ years ago)

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


 

SimplePortal 2.3.6 © 2008-2014, SimplePortal