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