Crypt
[ class tree: Crypt ] [ index: Crypt ] [ all elements ]

Class: Crypt_RC42

Source Location: /Crypt_RC42-0.9.0/Crypt/RC42.php

Class Overview


RC4 stream cipher routines implementation.


Author(s):

Version:

  • $Revision: 304006 $

Variables

Methods


Inherited Variables

Inherited Methods


Class Details

[line 68]
RC4 stream cipher routines implementation.

in PHP5(!) based on code written by Damien Miller <djm@mindrot.org> This class BREAKS COMPABILITY with earlier PHP 4 versions of the RC4 class. PHP 4 versions are available at http://pear.php.net/package/Crypt_RC42, download version 1.x

Basic usage of this class

  1.  $key "pear";
  2.  $message "PEAR rulez!";
  3.  
  4.  $rc4 = new Crypt_RC42();
  5.  $rc4->key($key);
  6.  echo "Original message: $message <br />\n";
  7.  
  8.  $message $rc4->encrypt($message);
  9.  $safe_codedmessage base64_encode($message);
  10.  echo "Encrypted message: $safe_codedmessage <br />\n";
  11.  
  12.  $message $rc4->decrypt($message);
  13.  echo "Decrypted message: $message <br />\n";

Another example how the class can be used

  1.  $origmessage "PEAR Rulez!";
  2.  
  3.  $rc4 = new Crypt_RC42("pear");
  4.  $codedmessage $rc4->encrypt($origmessage);
  5.  $safe_codedmessage base64_encode($codedmessage);
  6.  echo "Encrypted message: $safe_codedmessage <br />\n";

Note: The encrypted output is binary, and therefore cannot be properly displayed in shell or a browser. If you would like to display, please use the base64_encode function as above.

  • Author: Dave Mertens <zyprexia@php.net>
  • Version: $Revision: 304006 $
  • Access: public


[ Top ]


Class Variables

$i =  0

[line 84]

First Part of encryption matrix
  • Access: protected

Type:   array


[ Top ]

$j =  0

[line 92]

Second part of encryption matrix
  • Access: protected

Type:   array


[ Top ]

$key =

[line 100]

symmetric key used for encryption.
  • Access: protected

Type:   string


[ Top ]

$s = array()

[line 76]

Contains salt key used by en(de)cryption function
  • Access: protected

Type:   array


[ Top ]



Method Detail

__construct (Constructor)   [line 111]

void __construct( [string $key = null])

Constructor for encryption class Pass encryption key to key()
  • See: Key()
  • Access: public

Parameters:

string   $key   —  a key which will be used for encryption

[ Top ]

decrypt   [line 143]

string decrypt( string $paramstr)

Decrypt function
  • Return: Decrypted string
  • Access: public

Parameters:

string   $paramstr   —  string that will decrypted

[ Top ]

encrypt   [line 130]

string encrypt( string $paramstr)

Encrypt function

Note: The encrypted output of this function isa binary string, and therefore cannot be properly displayed in shell or a browser. If you would like to display, please use the base64_encode function before before output.

  • Return: Encrypted string
  • Access: public

Parameters:

string   $paramstr   —  string that will decrypted

[ Top ]

key   [line 156]

void key( string $key)

Assign encryption key to class
  • Access: public

Parameters:

string   $key   —  Key which will be used for encryption

[ Top ]

_crypt   [line 205]

Encrypted _crypt( string $paramstr)

(en/de) crypt function.

Function can be used for encrypting and decrypting a message

  • Return: or decrypted message
  • Access: protected

Parameters:

string   $paramstr   —  string that will encrypted

[ Top ]

_initializeKey   [line 242]

void _initializeKey( string $key)

This method prevents changes to the key during the encryption procedure.
  • Todo: Implement error handling!
  • Access: protected

Parameters:

string   $key   —  key which will be used for encryption

[ Top ]

__get   [line 169]

string __get( string $property)

The only way for retrieving the encryption key
  • Return: Enecryption key
  • Access: public

Parameters:

string   $property   —  Only property 'key' is supported

[ Top ]

__set   [line 186]

void __set( string $property, string $value)

Alternative way to set the encryption key
  • Access: public

Parameters:

string   $property   —  Only property 'key' is supported
string   $value   —  Value for property

[ Top ]


Documentation generated on Mon, 11 Mar 2019 15:39:20 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.