| @@ 92-126 (lines=35) @@ | ||
| 89 | * crypt a string |
|
| 90 | * @param string $text |
|
| 91 | */ |
|
| 92 | function encryptOld($text, $personalSalt = "") |
|
| 93 | { |
|
| 94 | if (empty($personalSalt) === false) { |
|
| 95 | return trim( |
|
| 96 | base64_encode( |
|
| 97 | mcrypt_encrypt( |
|
| 98 | MCRYPT_RIJNDAEL_256, |
|
| 99 | $personalSalt, |
|
| 100 | $text, |
|
| 101 | MCRYPT_MODE_ECB, |
|
| 102 | mcrypt_create_iv( |
|
| 103 | mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), |
|
| 104 | MCRYPT_RAND |
|
| 105 | ) |
|
| 106 | ) |
|
| 107 | ) |
|
| 108 | ); |
|
| 109 | } |
|
| 110 | ||
| 111 | // If $personalSalt is not empty |
|
| 112 | return trim( |
|
| 113 | base64_encode( |
|
| 114 | mcrypt_encrypt( |
|
| 115 | MCRYPT_RIJNDAEL_256, |
|
| 116 | SALT, |
|
| 117 | $text, |
|
| 118 | MCRYPT_MODE_ECB, |
|
| 119 | mcrypt_create_iv( |
|
| 120 | mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), |
|
| 121 | MCRYPT_RAND |
|
| 122 | ) |
|
| 123 | ) |
|
| 124 | ) |
|
| 125 | ); |
|
| 126 | } |
|
| 127 | ||
| 128 | /** |
|
| 129 | * decryptOld() |
|
| @@ 133-162 (lines=30) @@ | ||
| 130 | * |
|
| 131 | * decrypt a crypted string |
|
| 132 | */ |
|
| 133 | function decryptOld($text, $personalSalt = "") |
|
| 134 | { |
|
| 135 | if (!empty($personalSalt)) { |
|
| 136 | return trim( |
|
| 137 | mcrypt_decrypt( |
|
| 138 | MCRYPT_RIJNDAEL_256, |
|
| 139 | $personalSalt, |
|
| 140 | base64_decode($text), |
|
| 141 | MCRYPT_MODE_ECB, |
|
| 142 | mcrypt_create_iv( |
|
| 143 | mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), |
|
| 144 | MCRYPT_RAND |
|
| 145 | ) |
|
| 146 | ) |
|
| 147 | ); |
|
| 148 | } else { |
|
| 149 | return trim( |
|
| 150 | mcrypt_decrypt( |
|
| 151 | MCRYPT_RIJNDAEL_256, |
|
| 152 | SALT, |
|
| 153 | base64_decode($text), |
|
| 154 | MCRYPT_MODE_ECB, |
|
| 155 | mcrypt_create_iv( |
|
| 156 | mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), |
|
| 157 | MCRYPT_RAND |
|
| 158 | ) |
|
| 159 | ) |
|
| 160 | ); |
|
| 161 | } |
|
| 162 | } |
|
| 163 | ||
| 164 | /** |
|
| 165 | * encrypt() |
|