Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

(no description)

File Size: 224 lines (6 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

Horde_Secret:: (8 methods):
  __construct()
  write()
  read()
  _getCipherOb()
  setKey()
  getKey()
  clearKey()
  _setCookie()


Class: Horde_Secret  - X-Ref

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.

__construct($params = array()   X-Ref
Constructor.

param: array $params  Configuration parameters:

write($key, $message)   X-Ref
Take a small piece of data and encrypt it with a key.

param: string $key      The key to use for encryption.
param: string $message  The plaintext message.
return: string  The ciphertext message.

read($key, $ciphertext)   X-Ref
Decrypt a message encrypted with write().

param: string $key      The key to use for decryption.
param: string $message  The ciphertext message.
return: string  The plaintext message.

_getCipherOb($key)   X-Ref
Returns the cached crypt object.

param: string $key  The key to use for [de|en]cryption. Only the first
return: Horde_Crypt_Blowfish  The crypt object.

setKey($keyname = self::DEFAULT_KEY)   X-Ref
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.

param: string $keyname  The name of the key to set.
return: string  The secret key that has been generated.

getKey($keyname = self::DEFAULT_KEY)   X-Ref
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.

param: string $keyname  The name of the key to get.
return: string  The secret key.

clearKey($keyname = self::DEFAULT_KEY)   X-Ref
Clears a secret key entry from the current cookie.

param: string $keyname  The name of the key to clear.
return: boolean  True if key existed, false if not.

_setCookie($keyname, $key)   X-Ref
Sets the cookie with the given keyname/key.

param: string $keyname  The name of the key to set.
param: string $key      The key to use for encryption.