PHP Class FOF30\Encrypt\Aes

显示文件 Open project: akeeba/fof Class Usage Examples

Public Methods

Method Description
__construct ( string $key, integer $strength = 256, string $mode = 'cbc' ) Initialise the AES encryption object
decryptString ( string $stringToDecrypt, boolean $base64encoded = true ) : string Decrypts a ciphertext into a plaintext string using AES
encryptString ( string $stringToEncrypt, boolean $base64encoded = true ) : string Encrypts a string using AES
isSupported ( Phpfunc $phpfunc = null ) : boolean Is AES encryption supported by this PHP installation?

Method Details

__construct() public method

Initialise the AES encryption object
public __construct ( string $key, integer $strength = 256, string $mode = 'cbc' )
$key string The encryption key (password). It can be a raw key (32 bytes) or a passphrase.
$strength integer Bit strength (128, 192 or 256)
$mode string Ecnryption mode. Can be ebc or cbc. We recommend using cbc.

decryptString() public method

Decrypts a ciphertext into a plaintext string using AES
public decryptString ( string $stringToDecrypt, boolean $base64encoded = true ) : string
$stringToDecrypt string The ciphertext to decrypt. The first 16 bytes of the raw string must contain the IV (initialisation vector).
$base64encoded boolean Should I Base64-decode the data before decryption?
return string The plain text string

encryptString() public method

Encrypts a string using AES
public encryptString ( string $stringToEncrypt, boolean $base64encoded = true ) : string
$stringToEncrypt string The plaintext to encrypt
$base64encoded boolean Should I Base64-encode the result?
return string The cryptotext. Please note that the first 16 bytes of the raw string is the IV (initialisation vector) which is necessary for decoding the string.

isSupported() public static method

Is AES encryption supported by this PHP installation?
public static isSupported ( Phpfunc $phpfunc = null ) : boolean
$phpfunc FOF30\Utils\Phpfunc
return boolean