Class Util
Slim HTTP Utilities
This class provides useful methods for handling HTTP requests.
Methods summary
public static
array|string
|
#
stripSlashesIfMagicQuotes( mixed $rawData, mixed $overrideStripSlashes = null )
Strip slashes from string or array
Strip slashes from string or array
This method strips slashes from its input. By default, this method will only
strip slashes from its input if magic quotes are enabled. Otherwise, you may
override the magic quotes setting with either TRUE or FALSE as the send argument
to force this method to strip or not strip slashes from its input.
Returns
array|string
Var
array|string $rawData
|
protected static
array|string
|
#
_stripSlashes( array|string $rawData )
Strip slashes from string or array
Strip slashes from string or array
Parameters
- $rawData
array|string $rawData
Returns
array|string
|
public static
string
|
#
encrypt( string $data, string $key, string $iv, array $settings = array() )
Encrypt data
This method will encrypt data using a given key, vector, and cipher. By
default, this will encrypt data using the RIJNDAEL/AES 256 bit cipher. You may
override the default cipher and cipher mode by passing your own desired cipher
and cipher mode as the final key-value array argument.
Parameters
- $data
string $data The unencrypted data
- $key
string $key The encryption key
- $iv
string $iv The encryption initialization vector
- $settings
array $settings Optional key-value array with custom algorithm and mode
Returns
string
|
public static
string
|
#
decrypt( string $data, string $key, string $iv, array $settings = array() )
Decrypt data
This method will decrypt data using a given key, vector, and cipher. By
default, this will decrypt data using the RIJNDAEL/AES 256 bit cipher. You may
override the default cipher and cipher mode by passing your own desired cipher
and cipher mode as the final key-value array argument.
Parameters
- $data
string $data The encrypted data
- $key
string $key The encryption key
- $iv
string $iv The encryption initialization vector
- $settings
array $settings Optional key-value array with custom algorithm and mode
Returns
string
|
public static
|
#
encodeSecureCookie( string $value, integer $expires, string $secret, integer $algorithm, integer $mode )
Encode secure cookie value
Encode secure cookie value
This method will create the secure value of an HTTP cookie. The cookie value
is encrypted and hashed so that its value is secure and checked for integrity
when read in subsequent requests.
Parameters
- $value
string $value The unsecure HTTP cookie value
- $expires
integer $expires The UNIX timestamp at which this cookie will expire
- $secret
string $secret The secret key used to hash the cookie value
- $algorithm
integer $algorithm The algorithm to use for encryption
- $mode
integer $mode The algorithm mode to use for encryption
|
public static
|
#
decodeSecureCookie( string $value, integer $secret, string $algorithm, integer $mode )
Decode secure cookie value
Decode secure cookie value
This method will decode the secure value of an HTTP cookie. The cookie value
is encrypted and hashed so that its value is secure and checked for integrity
when read in subsequent requests.
Parameters
- $value
string $value The secure HTTP cookie value
- $secret
integer $expires The UNIX timestamp at which this cookie will expire
- $algorithm
string $secret The secret key used to hash the cookie value
- $mode
integer $algorithm The algorithm to use for encryption
|