補碼前的數(shù)據(jù):b31d2458000000000000865067022840600001
補碼后的數(shù)據(jù):b31d24580000000000008650670228406000010d0d0d0d0d0d0d0d0d0d0d0d0d
// pkcs5_pad 補碼算法
private static function pkcs5_pad($text, $blocksize){
$pad = $blocksize - (strlen($text) % $blocksize);
return $text . str_repeat(chr($pad), $pad);
}
// 這段代碼有問題
public static function remove_pkcs_pad($decrypted)
{
$dec_s = strlen($decrypted);
$padding = ord($decrypted[ $dec_s - 1 ]);
$decrypted = substr($decrypted, 0, - $padding);
return $decrypted;
}
// 該段代碼需要驗證
public function remove_pkcs_pad2()
{
$complement = substr($decrypted_hex, strlen($decrypted_hex) - 2, 2);
$complement = base_convert($complement, 16, 10);
if ($complement < strlen($decrypted_hex)) {
$decrypted_hex = substr($decrypted_hex, 0, -1 * $complement * 2);
}
}