\Horde_Secret

Provides an API for encrypting and decrypting small pieces of data with the use of a shared key stored in a cookie.

Copyright 1999-2017 Horde LLC (http://www.horde.org/)

See the enclosed file LICENSE for license information (LGPL). If you did not receive this file, see http://www.horde.org/licenses/lgpl21.

Summary

Methods
Properties
Constants
__construct()
write()
read()
setKey()
getKey()
clearKey()
No public properties found
DEFAULT_KEY
_getCipherOb()
_setCookie()
$_params
$_cipherCache
$_keyCache
N/A
No private methods found
No private properties found
N/A

Constants

DEFAULT_KEY

DEFAULT_KEY

Generic, default keyname.

Properties

$_params

$_params : array

Configuration parameters.

Type

array

$_cipherCache

$_cipherCache : array

Cipher cache.

Type

array

$_keyCache

$_keyCache : array

Key cache.

Type

array

Methods

__construct()

__construct(array  $params = array()) 

Constructor.

Parameters

array $params

Configuration parameters:

  • cookie_domain: (string) The cookie domain.
  • cookie_path: (string) The cookie path.
  • cookie_ssl: (boolean) Only transmit cookie securely?
  • session_name: (string) The cookie session name.

write()

write(string  $key, string  $message) : string

Take a small piece of data and encrypt it with a key.

Parameters

string $key

The key to use for encryption.

string $message

The plaintext message.

Throws

\Horde_Secret_Exception

Returns

string —

The ciphertext message.

read()

read(string  $key,   $ciphertext) : string

Decrypt a message encrypted with write().

Parameters

string $key

The key to use for decryption.

$ciphertext

Throws

\Horde_Secret_Exception

Returns

string —

The plaintext message.

setKey()

setKey(string  $keyname = self::DEFAULT_KEY) : string

Generate a secret key (for encryption), either using a random string and storing it in a cookie if the user has cookies enabled, or munging some known values if they don't.

Parameters

string $keyname

The name of the key to set.

Returns

string —

The secret key that has been generated.

getKey()

getKey(string  $keyname = self::DEFAULT_KEY) : string

Return a secret key, either from a cookie, or if the cookie isn't there, assume we are using a munged version of a known base value.

Parameters

string $keyname

The name of the key to get.

Returns

string —

The secret key.

clearKey()

clearKey(string  $keyname = self::DEFAULT_KEY) : boolean

Clears a secret key entry from the current cookie.

Parameters

string $keyname

The name of the key to clear.

Returns

boolean —

True if key existed, false if not.

_getCipherOb()

_getCipherOb(string  $key) : \Horde_Crypt_Blowfish

Returns the cached crypt object.

Parameters

string $key

The key to use for [de|en]cryption. Only the first 56 bytes of this string is used.

Throws

\Horde_Secret_Exception

Returns

\Horde_Crypt_Blowfish —

The crypt object.

_setCookie()

_setCookie(string  $keyname, string  $key) 

Sets the cookie with the given keyname/key.

Parameters

string $keyname

The name of the key to set.

string $key

The key to use for encryption.