Contents
Articles
Behaviors
Books
Director News
Director Web Sites
FAQ
Games
Mailing Lists
News Groups
Project Examples
Reviews
Software
Tools
Useful Web Sites
Utilities
Xtras

Don't miss these
simODBC Xtra
Export/Import Text and Filed Members for proofing
Find CD Drives letter quikly
keyboard input control
cXtraPrinterDoc
Accessing Keys to Control a Sprite
Mouse Up Trigger-Alphamania
Countdown Timer
DirSaver
Convert between bases-String to Integer
 

 

 

Behavior Text Encryption

Added on 1/8/2001

 

Compatibilities:
behavior D7 D8 PC Shockwave

Rating:

Author: JaiGanesh

Just create a text field "entext" and two buttons, one for encryption and one for decryption. Attach the codes and start encrypting.

Logic for encryption
********************

global ftext
-- Each element in this list is a character entered in the field "entext"
global keylist
-- A list containing the key generated for each character.
global orvalues
-- A list containing the original ascii values.
global tch
global decr
-- A flag set when decryption is activated
global encr
-- A flag which is set when encryption is activated.

property totchars
-- Total number of characters entered in field "entext"
property tchar
property rkey
-- A random number between -700 and 700 which is added to the ascii value of
-- each character entered.

on mouseUp
  if encr = 0 then
    x =  the text of field "entext"
    if x = "" then
      alert "Please enter text into the field"
      updatestage
    end if
    totchars = the number of chars of field "entext"
    tch = totchars
    repeat with y = 1 to totchars
      append ftext, char y of field "entext"
      updatestage
    end repeat
    set the text of field "entext" to empty
    repeat with z = 1 to totchars
      -- Adding a random key generated to the key list
      rkey = random(-700,700)
      append keylist, rkey
      put keylist
      tchar = chartonum(ftext[z]) + rkey
      append orvalues, tchar
      put tchar after member "entext"
    end repeat
    encr = 1
    decr = 0
  else
    nothing
  end if
end

************************************************************

Logic for Decryption
********************

global keylist
global orvalues
global tch
global decr
global encr
property tvar

on mouseUp
  if decr = 0 then
    set the text of field "entext" to empty
    updatestage
    repeat with s = 1 to tch
      tvar = numtochar(orvalues[s] - keylist[s])
      put tvar after field "entext"
      updatestage
    end repeat
    decr = 1
    encr = 0
  else
    nothing
  end if
end

 


Contact

MMI
36 South Court Sq
Suite 300
Newnan, GA 30263
USA

Send e-mail