'===========================================================================
' Subject: SIMPLE ENCRYPT/DECRYPT ROUTINE     Date: 06-21-99 (09:47)       
'  Author: Cl udio A. Pi‡arra                 Code: QB, QBasic, PDS        
'  Origin: korby@mail.pt                    Packet: ALGOR.ABC
'===========================================================================
'----------------------------------------------------------------------------
'Prog. Name: SEDR - Simple Encryption/Decryption Routine
'Freeware (C) Cl udio A. Pi‡arra - 1999
'Date: 99.06.14               Time: 20:38:55
'Destiny: ABC Packets
'----------------------------------------------------------------------------
'This is a VEEEEEEEEEEEEEEEEERRRRRY simple encryption/decryption routine I
'made to prove it's EASY to create an encryption routine.
'The code is self explanatory, I guess.
'I've included NO error checking routine. I'm lazy, so sue me!...
'U know this routine can b improved and speeded up, but if it works,
'why worry?
'Anyway, if u change this in any way, mail it to me(E-mail adress bellow).
'
'BTW, if u include this in any of your programs, please, send me the program
'and put my name in the Credits section.
'
'If you r reading this send the message bellow as SUBJECT to the mail bellow:
'Message: BASIC IS NOT FOR BASIC PEOPLE!
'E-Mail adress: a_rita@yahoo.com
'Oh, don't expect any answer from this one...

'For comments, sugestions, critics, simply say Hi, etc. these r my mails
'born_in_portugal@yahoo.com
'korby@mail.pt
'
'I guess it's all.
'Bye.
'                                          Signed:
'                                          Cl udio
'
'P. S. - Sorry 4 my bad english...
'-----------------------------Prog. beginning--------------------------------
'$DYNAMIC
DEFINT A-Z
CLEAR
CLS

LINE INPUT "Text to Encode:", Text$
LINE INPUT "PASSWORD:", Pass$
CLS
PRINT
PRINT "Original Text: "; Text$
PRINT "PASSWORD:"; Pass$

FOR passencode = 1 TO LEN(Pass$)
  tmp$ = MID$(Pass$, passencode, 1)
  Pass# = Pass# + ASC(tmp$)
NEXT
Pass# = Pass# / LEN(Pass$)

EncodedText$ = ""
Size = LEN(Text$)
FOR Crypt = 1 TO Size
  Txt$ = MID$(Text$, Crypt, 1)
  IF Crypt = 1 THEN
    EncodedText$ = STR$(ASC(Txt$) + Pass#) + CHR$(0)
  ELSE
    EncodedText$ = EncodedText$ + LTRIM$(RTRIM$(STR$(ASC(Txt$) + Pass#))) + CHR$(0)
  END IF
NEXT Crypt

EncodedText$ = MID$(EncodedText$, 2, LEN(EncodedText$) - 1)
PRINT
PRINT "Encoded Text:"
PRINT EncodedText$

Size2 = LEN(EncodedText$)
Place = 1
DO UNTIL Place >= Size2
  Nul = INSTR(Place, EncodedText$, CHR$(0))
  Size = Nul - Place
  Txt = VAL(MID$(EncodedText$, Place, Size)) - Pass#
  unEncodedText$ = unEncodedText$ + CHR$(Txt)
  Place = Nul + 1
LOOP

PRINT
PRINT "unEncoded Text: "; unEncodedText$
END
'Pretty simple, isn't it?
'---------------------------------Prog. end----------------------------------
