TGC Codebase Backup



Password Encryption System by Peace

10th Nov 2004 14:38
Summary

Encrypting using password and xor operator



Description

This file en/decryption system only use one and same function. For encryption call it once and for decryption once again. You can enter a own password with no limmit of characters (always remember). For deeper encryption try using signs like "*%�§&#...". The system based on the xor operant, same like "~~", I must use it in this way coz my editor don't accept the command xor! It's very recommend to work with text, gfx and files wich never should change by others!



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    Remstart
   ------------------------------------------------------------------
   Author:        Volker Stepprath of Testaware
   Project:       Password Encryption System
   Version:       0.00.001 ;D
   Language:      DarkBASIC Professional v1.057
   Description:   File en/decrypt using password and xor operator
   Date:          10. November 2004
   ------------------------------------------------------------------
   Hint 1:        Call function first as encrypt and twice to decrypt
   Hint 2:        Use function as include in your own sources
   Hint 3:        For deep encryption use characters like "%&!#*?..."
   ------------------------------------------------------------------
Remend

xFileName$="Atomix 2004.exe"        : Rem * Name of the file to en/decrypt
xPassWord$="DarkBASIC Professional" : Rem * Password (try your own characters)

_EncryptFile(xFileName$,xPassWord$) : Rem * Call function to en/decrypt file

FUNCTION _EncryptFile(xFileName$,xPassWord$)

   open to read 1,xFileName$
   make memblock from file 1,1
   close file 1

   xFileSize=get memblock size(1)-1
   xPassSize=len(xPassWord$)

   for a=0 to xFileSize
      b=memblock byte(1,a)
      if b<>0
         inc c : if c>xPassSize then c=1
         b=b ~~ asc(mid$(xPassWord$,c))
         if b<>0 then write memblock byte 1,a,b
      endif
   next a

   delete file xFileName$

   open to write 1,xFileName$
   for a=0 to xFileSize
      write byte 1,memblock byte(1,a)
   next a
   close file 1

   delete memblock 1

ENDFUNCTION