Class JCrypt
JCrypt is a Joomla Platform class for handling basic encryption/decryption of
data.
Methods summary
public
|
#
__construct( JCryptCipher $cipher = null, JCryptKey $key = null )
Object Constructor takes an optional key to be used for
encryption/decryption. If no key is given then the secret word from the
configuration object is used.
Object Constructor takes an optional key to be used for
encryption/decryption. If no key is given then the secret word from the
configuration object is used.
Parameters
- $cipher
JCryptCipher - $cipher The encryption cipher object.
- $key
JCryptKey - $key The encryption key[/pair)].
Since
12.1
|
public
string
|
#
decrypt( string $data )
Method to decrypt a data string.
Method to decrypt a data string.
Parameters
- $data
string - $data The encrypted string to decrypt.
Returns
string - The decrypted data string.
Throws
Since
12.1
|
public
string
|
#
encrypt( string $data )
Method to encrypt a data string.
Method to encrypt a data string.
Parameters
- $data
string - $data The data string to encrypt.
Returns
string - The encrypted data string.
Since
12.1
|
public
JCryptKey
|
#
generateKey( array $options = array() )
Method to generate a new encryption key[/pair] object.
Method to generate a new encryption key[/pair] object.
Parameters
- $options
array - $options Key generation options.
Returns
Since
12.1
|
public
JCrypt
|
#
setKey( JCryptKey $key )
Method to set the encryption key[/pair] object.
Method to set the encryption key[/pair] object.
Parameters
Returns
Since
12.1
|
public static
string
|
#
genRandomBytes( integer $length = 16 )
Generate random bytes.
Parameters
- $length
integer - $length Length of the random data to generate
Returns
string - Random binary data
Since
12.1
|
public static
boolean
|
#
timingSafeCompare( string $known, string $unknown )
A timing safe comparison method.
A timing safe comparison method.
This defeats hacking attempts that use timing based attack vectors.
NOTE: Length will leak.
Parameters
- $known
string - $known A known string to check against.
- $unknown
string - $unknown An unknown string to check.
Returns
boolean - True if the two strings are exactly the same.
Since
3.2
|
public static
boolean
|
#
hasStrongPasswordSupport( )
Tests for the availability of updated crypt(). Based on a method by Anthony
Ferrera
Tests for the availability of updated crypt(). Based on a method by Anthony
Ferrera
Deprecated
4.0
Returns
boolean - Always returns true since 3.3
Since
3.2
Link
Note
To be removed when PHP 5.3.7 or higher is the minimum supported version.
|
public static
integer
|
#
safeStrlen( string $str )
Safely detect a string's length
Safely detect a string's length
This method is derived from \ParagonIE\Halite\Util::safeStrlen()
Parameters
- $str
string - $str String to check the length of
Returns
integer
Throws
Since
3.5
Ref
mbstring.func_overload
|
public static
string
|
#
safeSubstr( string $str, integer $start, integer $length = null )
Safely extract a substring
Safely extract a substring
This method is derived from \ParagonIE\Halite\Util::safeSubstr()
Parameters
- $str
string - $str The string to extract the substring from
- $start
integer - $start The starting position to extract from
- $length
integer - $length The length of the string to return
Returns
string
Since
3.5
|
Magic methods summary