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