Packagecalista.hash
Classpublic class RXOR
InheritanceRXOR Inheritance Object

XOR Encryption is a popular encryption algorithm that is used in many browsers and it is blatantly simpleand fairly secure. The XOR Encryption algorithm is an example of a Symmetric Encryption algorithm. This means that the same key is used for both encryption and decryption. In the case of XOR Encryption, this is true because XOR is a two-way function which means that the function can easily be undone. In the following paper the standard XOR Encryption algorithm will be introduced along with a modification. The modification comes in the form of creating random permutations of the key.

Example :

     import calista.hash.RXOR ;
     
     var rxor:RXOR = new RXOR() ;
     
     var cipher:String ;
     var source:String ;
     
     cipher = rxor.encrypt( "hello world" , 0x1234 ) ;
     trace( cipher ) ; // ቜ⌤㑾䅏ቛ⍡㑥䅌ቆ⌭㑶
     
     source = rxor.encrypt( cipher , 0x1234 ) ;
     trace( source ) ; // hello world
     

See more information about XOR encryption : http://www.acm.org/crossroads/xrds11-3/xorencrypt.html



Public Methods
 MethodDefined By
  
Creates a new RXOR instance.
RXOR
  
encrypt(source:String, key:uint = 0x1234):String
Encrypt the specified text with the passed-in key.
RXOR
  
encrypt(source:String, key:uint = 0x1234):String
[static] Encrypt the specified text with the passed-in key.
RXOR
  
rotbit(key:uint):uint
Rotates the bits of the key by block of 4bits (eg.
RXOR
Constructor Detail
RXOR()Constructor
public function RXOR()

Creates a new RXOR instance.

Method Detail
encrypt()method
public function encrypt(source:String, key:uint = 0x1234):String

Encrypt the specified text with the passed-in key. Note : we force the key to be 16bit (0xffff) so the hex can be converted to unicode

Parameters

source:String — The source to encrypt.
 
key:uint (default = 0x1234) — The key used to encrypt.

Returns
String
encrypt()method 
public static function encrypt(source:String, key:uint = 0x1234):String

Encrypt the specified text with the passed-in key. Note : we force the key to be 16bit (0xffff) so the hex can be converted to unicode

Example :

         import calista.hash.RXOR ;
         
         var cipher:String ;
         var source:String ;
         
         cipher = RXOR.encrypt( "hello world" , 0x1234 ) ;
         trace( cipher ) ; // ቜ⌤㑾䅏ቛ⍡㑥䅌ቆ⌭㑶
         
         source = RXOR.encrypt( cipher , 0x1234 ) ;
         trace( source ) ; // hello world
         

Parameters

source:String — The source to encrypt.
 
key:uint (default = 0x1234) — The key used to encrypt.

Returns
String
rotbit()method 
public function rotbit(key:uint):uint

Rotates the bits of the key by block of 4bits (eg. 0xF). for ex: if your input is 0x1234 it returns 0x2341

Parameters

key:uint

Returns
uint — the rotated bits