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