\CryptoManana\CompatibilityNativeRc4

Class NativeRc4 - Pure PHP implementation of the RC4-128 algorithm.

Summary

Methods
Properties
Constants
getInstance()
__wakeup()
__sleep()
__toString()
encryptData()
decryptData()
No public properties found
KEY_SIZE
__construct()
keyScheduling()
transformData()
No protected properties found
N/A
__clone()
No private properties found
N/A

Constants

KEY_SIZE

KEY_SIZE

The internal secret key size measured in raw bytes length for the algorithm

Methods

getInstance()

getInstance() : static|null

Gives a unified access point for the current object instance.

Returns

static|null —

An instance.

__wakeup()

__wakeup() 

Lock the reinitialization and unserialization abilities of the class.

__sleep()

__sleep() 

Lock the serialization abilities of the class.

__toString()

__toString() : string

Return the name of the current defined class that extends the class.

Returns

string —

Name of the class.

encryptData()

encryptData(string  $secretKey, string  $plainData) : string

Encrypts the given plain data.

Parameters

string $secretKey

The secret key.

string $plainData

The plain data for encryption.

Throws

\Exception

Validation errors.

Returns

string —

The cipher/encrypted data.

decryptData()

decryptData(string  $secretKey, string  $cipherData) : string

Decrypts the given cipher data.

Parameters

string $secretKey

The secret key.

string $cipherData

The encrypted input string.

Throws

\Exception

Validation errors.

Returns

string —

The decrypted/plain data.

__construct()

__construct() 

Locks the creation of new objects but allows static creation and extending.

keyScheduling()

keyScheduling(string  $key) : array

The key-scheduling algorithm for the initialize of the permutation array.

Parameters

string $key

The secret key.

Returns

array —

The key stream permutation array.

transformData()

transformData(string  $key, string  $data) : string

The stream transformation operation realized via the internal pseudo-random generation algorithm.

Parameters

string $key

The secret key.

string $data

The data for transformation.

Throws

\Exception

Validation errors.

Returns

string —

The encrypted or decrypted data.

__clone()

__clone() 

Lock the ability to clone properties and create a new dynamic instance of the class.