function Pin2PinBlockWithCardNO(&$sPin, &$sCardNO) { global $log; $sPinBuf = Pin2PinBlock($sPin); $iCardLen = strlen($sCardNO); // $log->LogInfo("CardNO length : " . $iCardLen); if ($iCardLen <= 10) { return 1; } elseif ($iCardLen == 11) { $sCardNO = "00" . $sCardNO; } elseif ($iCardLen == 12) { $sCardNO = "0" . $sCardNO; } $sPanBuf = FormatPan($sCardNO); $sBuf = array(); for ($i = 0; $i < 8; $i++) { // $sBuf[$i] = $sPinBuf[$i] ^ $sPanBuf[$i]; //十进制 // $sBuf[$i] = vsprintf("%02X", ($sPinBuf[$i] ^ $sPanBuf[$i])); $sBuf[$i] = vsprintf("%c", $sPinBuf[$i] ^ $sPanBuf[$i]); } unset($sPinBuf); unset($sPanBuf); // return $sBuf; $sOutput = implode("", $sBuf); //数组转换为字符串 return $sOutput; }
function Pin2PinBlockWithCardNO(&$sPin, &$sCardNO) { global $log; $sPinBuf = Pin2PinBlock($sPin); $iCardLen = strlen($sCardNO); if ($iCardLen <= 10) { return 1; } elseif ($iCardLen == 11) { $sCardNO = "00" . $sCardNO; } elseif ($iCardLen == 12) { $sCardNO = "0" . $sCardNO; } $sPanBuf = FormatPan($sCardNO); $sBuf = array(); for ($i = 0; $i < 8; $i++) { $sBuf[$i] = vsprintf("%c", $sPinBuf[$i] ^ $sPanBuf[$i]); } unset($sPinBuf); unset($sPanBuf); $sOutput = implode("", $sBuf); return $sOutput; }
/** * 密码转PIN,并附带上卡号 * @param string $sPin 密码明文字符串 * @param string $sCardNO 卡号 * @return string */ function Pin2PinBlockWithCardNO(&$sPin, &$sCardNO) { $resArr = ['code' => 0]; $sPinBuf = Pin2PinBlock($sPin); $iCardLen = strlen($sCardNO); if ($iCardLen <= 10) { $resArr['code'] = 1; $resArr['message'] = '卡号长度不正确'; } elseif ($iCardLen == 11) { $sCardNO = "00" . $sCardNO; } elseif ($iCardLen == 12) { $sCardNO = "0" . $sCardNO; } $sPanBuf = FormatPan($sCardNO); $sBuf = []; for ($i = 0; $i < 8; $i++) { $sBuf[$i] = vsprintf("%c", $sPinBuf[$i] ^ $sPanBuf[$i]); } unset($sPinBuf); unset($sPanBuf); $resArr['data'] = implode("", $sBuf); return $resArr; //数组转换为字符串 }