JCrypt

JCrypt is a Joomla Platform class for handling basic encryption/decryption of data.

since

12.1

package

Joomla.Platform

Methods

__construct

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.

__construct(\JCryptCipher $cipher = null, \JCryptKey $key = null) 
since

12.1

Arguments

$cipher

\JCryptCipherThe encryption cipher object.

$key

\JCryptKeyThe encryption key[/pair)].

decrypt

Method to decrypt a data string.

decrypt(string $data) : string
since

12.1

throws

\InvalidArgumentException

Arguments

$data

stringThe encrypted string to decrypt.

Response

stringThe decrypted data string.

encrypt

Method to encrypt a data string.

encrypt(string $data) : string
since

12.1

Arguments

$data

stringThe data string to encrypt.

Response

stringThe encrypted data string.

generateKey

Method to generate a new encryption key[/pair] object.

generateKey(array $options = array()) : \JCryptKey
since

12.1

Arguments

$options

arrayKey generation options.

Response

\JCryptKey

genRandomBytes

Generate random bytes.

genRandomBytes(integer $length = 16) : string
static
since

12.1

Arguments

$length

integerLength of the random data to generate

Response

stringRandom binary data

hasStrongPasswordSupport

Tests for the availability of updated crypt().

hasStrongPasswordSupport() : boolean
static deprecated

Based on a method by Anthony Ferrera

note

To be removed when PHP 5.3.7 or higher is the minimum supported version.

link

https://github.com/ircmaxell/password_compat/blob/master/version-test.php

since

3.2

deprecated

4.0

Response

booleanAlways returns true since 3.3

safeStrlen

Safely detect a string's length

safeStrlen(string $str) : integer
static

This method is derived from \ParagonIE\Halite\Util::safeStrlen()

since

3.5

ref

mbstring.func_overload

throws

\RuntimeException

Arguments

$str

stringString to check the length of

Response

integer

safeSubstr

Safely extract a substring

safeSubstr(string $str, integer $start, integer $length = null) : string
static

This method is derived from \ParagonIE\Halite\Util::safeSubstr()

since

3.5

Arguments

$str

stringThe string to extract the substring from

$start

integerThe starting position to extract from

$length

integerThe length of the string to return

Response

string

setKey

Method to set the encryption key[/pair] object.

setKey(\JCryptKey $key) : \JCrypt
since

12.1

Arguments

$key

\JCryptKeyThe key object to set.

Response

\JCrypt

timingSafeCompare

A timing safe comparison method.

timingSafeCompare(string $known, string $unknown) : boolean
static

This defeats hacking attempts that use timing based attack vectors.

NOTE: Length will leak.

since

3.2

Arguments

$known

stringA known string to check against.

$unknown

stringAn unknown string to check.

Response

booleanTrue if the two strings are exactly the same.

Properties

_cipher

The encryption cipher object.

Type(s)

\JCryptCipher

_key

The encryption key[/pair)].

Type(s)

\JCryptKey