Joomla Platform  13.1
Documentation des API du framework Joomla Platform
 Tout Classes Espaces de nommage Fichiers Fonctions Variables Pages
simplecrypt.php
Aller à la documentation de ce fichier.
1 <?php
2 /**
3  * @package Joomla.Legacy
4  * @subpackage Simplecrypt
5  *
6  * @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
7  * @license GNU General Public License version 2 or later; see LICENSE
8  */
9 
10 defined('JPATH_PLATFORM') or die;
11 
12 /**
13  * JSimpleCrypt is a very simple encryption algorithm for encrypting/decrypting strings
14  *
15  * @package Joomla.Legacy
16  * @subpackage Simplecrypt
17  * @since 11.1
18  * @deprecated 12.3 (Platform) & 4.0 (CMS) - Use JCrypt instead.
19  */
21 {
22  /**
23  * Encryption/Decryption Key
24  *
25  * @var JCrypt
26  * @since 12.1
27  * @deprecated 12.3 Use JCrypt instead.
28  */
29  private $_crypt;
30 
31  /**
32  * Object Constructor takes an optional key to be used for encryption/decryption. If no key is given then the
33  * secret word from the configuration object is used.
34  *
35  * @param string $privateKey Optional encryption key
36  *
37  * @since 11.1
38  * @deprecated 12.3 Use JCrypt instead.
39  */
40  public function __construct($privateKey = null)
41  {
42  JLog::add('JSimpleCrypt is deprecated. Use JCrypt instead.', JLog::WARNING, 'deprecated');
43 
44  if (empty($privateKey))
45  {
46  $privateKey = md5(JFactory::getConfig()->get('secret'));
47  }
48 
49  // Build the JCryptKey object.
50  $key = new JCryptKey('simple', $privateKey, $privateKey);
51 
52  // Setup the JCrypt object.
53  $this->_crypt = new JCrypt(new JCryptCipherSimple, $key);
54  }
55 
56  /**
57  * Decrypt a string
58  *
59  * @param string $s String to decrypt
60  *
61  * @return string
62  *
63  * @since 11.1
64  * @deprecated 12.3 Use JCrypt instead.
65  */
66  public function decrypt($s)
67  {
68  return $this->_crypt->decrypt($s);
69  }
70 
71  /**
72  * Encrypt a string
73  *
74  * @param string $s String to encrypt
75  *
76  * @return string
77  *
78  * @since 11.1
79  * @deprecated 12.3 Use JCrypt instead.
80  */
81  public function encrypt($s)
82  {
83  return $this->_crypt->encrypt($s);
84  }
85 }