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
Foundation Flash 5
Mouse Up Trigger-Alphamania
Wait for DigitalVideo End
Limited Text Behavior
Paste Behavior (Ctrl + V)
Data Linker Xtra
Versiown
Date Time Xtra
FileXtra
DirectControl
 

 

 

Behavior RC4 Encryption Algorithm Script

Added on 4/9/2002

 

Compatibilities:
D7 D8 D8_5 Script Shockwave UK

Rating:

Author: psychicparrot (website)

RC4 is a stream cipher. Using a password, a string may be encrypted. By running the encrypted text through the same algorithm, the string becomes readable only when the password is the same as the one used during encryption. Great for protecting your high score tables or prefs files from prying eyes and itchy hacker fingers! ;) PsychicParrot.

Download PC Source
-- RC4 Algorithm
--
-- Adapted from VB code written by Luke Bailey
-- Copyright 2002 PsychicParrot
-- oracle@psychicparrot.com
--
-- You are welcome to use this script as you wish, but keep these comments intact please!
--

global sbox,ke,scn,srn,tempswap,a,b
global temp,i,j,k,cipherkey,cipher

on beginsprite
  
  sbox=[]
  ke=[]
  
end

on Security_RC4Initialise(strpwd)
  
  cipher=EMPTY
  intlength = strpwd.length
  sbox=[]
  ke=[]
  
  repeat with a=1 to 255
    
    ke[a]=chartonum(strpwd.char[(a mod intlength+1)..(a mod intlength+1)])
    sbox[a]=a
    
  end repeat
  
  b=0
  
  repeat with a=1 to 255
    b=((b+sbox[a]+ke[a]) mod 255)
    tempswap = sbox[a]
    sbox[a]=sbox[b]
    sbox[b]=tempswap
  end repeat
  
end

on Security_RC4(plaintxt)
  
  i=0
  j=0
  
  repeat with a=1 to plaintxt.length
    
    i=((i+1) mod 255)
    j=((j+sbox[i]) mod 255)
    temp=sbox[i]
    sbox[i]=sbox[j]
    sbox[j]=temp
    k=sbox[((sbox[i]+sbox[j]) mod 255)]
    cipherby=bitXor(chartonum(plaintxt.char[a..a]),k)
    cipher=cipher&numtochar(cipherby)
    
  end repeat
  
  RETURN cipher
  
end

 


Contact

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

Send e-mail