Overview

Packages

  • Secret

Classes

  • Horde_Secret
  • Horde_Secret_Exception
  • Overview
  • Package
  • Class
  • Tree

Class 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-2012 Horde LLC (http://www.horde.org/)

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

Package: Secret
Category: Horde
License: LGPL
Author: Chuck Hagenbuch chuck@horde.org
Author: Michael Slusarz slusarz@horde.org
Located at Horde/Secret.php
Methods summary
public
# __construct( array $params = array() )

Constructor.

Constructor.

Parameters

$params
<p>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.</p>
public string
# write( string $key, string $message )

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

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

Parameters

$key
The key to use for encryption.
$message
The plaintext message.

Returns

string
The ciphertext message.

Throws

Horde_Secret_Exception
public string
# read( string $key, string $ciphertext )

Decrypt a message encrypted with write().

Decrypt a message encrypted with write().

Parameters

$key
The key to use for decryption.
$ciphertext
$message The ciphertext message.

Returns

string
The plaintext message.

Throws

Horde_Secret_Exception
public string
# setKey( string $keyname = Horde_Secret::DEFAULT_KEY )

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

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

Parameters

$keyname
The name of the key to set.

Returns

string
The secret key that has been generated.
public string
# getKey( string $keyname = Horde_Secret::DEFAULT_KEY )

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.

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

$keyname
The name of the key to get.

Returns

string
The secret key.
public boolean
# clearKey( string $keyname = Horde_Secret::DEFAULT_KEY )

Clears a secret key entry from the current cookie.

Clears a secret key entry from the current cookie.

Parameters

$keyname
The name of the key to clear.

Returns

boolean
True if key existed, false if not.
Constants summary
string DEFAULT_KEY

Generic, default keyname.

Generic, default keyname.

# 'generic'
API documentation generated by ApiGen