| @@ 49-57 (lines=9) @@ | ||
| 46 | * | |
| 47 | * @return 删除填充补位后的明文 | |
| 48 | */ | |
| 49 | public function decode($text) | |
| 50 |     { | |
| 51 | $pad = ord(substr($text, -1)); | |
| 52 |         if ($pad < 1 || $pad > 32) { | |
| 53 | $pad = 0; | |
| 54 | } | |
| 55 | ||
| 56 | return substr($text, 0, (strlen($text) - $pad)); | |
| 57 | } | |
| 58 | } | |
| 59 | ||
| @@ 148-157 (lines=10) @@ | ||
| 145 | * | |
| 146 | * @return string | |
| 147 | */ | |
| 148 | public function decode($decrypted) | |
| 149 |     { | |
| 150 | $pad = ord(substr($decrypted, -1)); | |
| 151 | ||
| 152 |         if ($pad < 1 || $pad > $this->blockSize) { | |
| 153 | $pad = 0; | |
| 154 | } | |
| 155 | ||
| 156 | return substr($decrypted, 0, (strlen($decrypted) - $pad)); | |
| 157 | } | |
| 158 | ||
| 159 | /** | |
| 160 | * Encode string. | |