55 lines
1.8 KiB
JavaScript
55 lines
1.8 KiB
JavaScript
/**
|
|
* 最终验证 - 确认生成的卡号符合所有规律
|
|
*/
|
|
|
|
const { luhnCheck } = require('./src/shared/utils');
|
|
|
|
// 刚才生成的5张卡
|
|
const newCards = [
|
|
'6228367543886341|02|28|859',
|
|
'6228367547515052|03|26|649',
|
|
'6228367546095387|07|30|930',
|
|
'6228367544299692|04|30|852',
|
|
'6228367546840634|01|26|197'
|
|
];
|
|
|
|
console.log('=== 最终验证 ===\n');
|
|
console.log('验证新生成的5张卡:\n');
|
|
|
|
let allValid = true;
|
|
newCards.forEach((cardStr, index) => {
|
|
const [number, month, year, cvv] = cardStr.split('|');
|
|
const isValid = luhnCheck(number);
|
|
|
|
// 检查各项规律
|
|
const prefixOk = number.startsWith('622836754');
|
|
const lengthOk = number.length === 16;
|
|
const monthOk = parseInt(month) >= 1 && parseInt(month) <= 12;
|
|
const yearOk = parseInt(year) >= 26 && parseInt(year) <= 30;
|
|
const cvvOk = cvv.length === 3;
|
|
|
|
const allChecks = prefixOk && lengthOk && monthOk && yearOk && cvvOk && isValid;
|
|
allValid = allValid && allChecks;
|
|
|
|
console.log(`卡 ${index + 1}: ${cardStr}`);
|
|
console.log(` ├─ 前缀 622836754: ${prefixOk ? '✓' : '✗'}`);
|
|
console.log(` ├─ 长度 16位: ${lengthOk ? '✓' : '✗'}`);
|
|
console.log(` ├─ 月份 01-12: ${monthOk ? '✓' : '✗'}`);
|
|
console.log(` ├─ 年份 26-30: ${yearOk ? '✓' : '✗'}`);
|
|
console.log(` ├─ CVV 3位: ${cvvOk ? '✓' : '✗'}`);
|
|
console.log(` └─ Luhn校验: ${isValid ? '✓' : '✗'}\n`);
|
|
});
|
|
|
|
console.log('=== 结论 ===');
|
|
if (allValid) {
|
|
console.log('✓ 所有卡号完全符合规律!');
|
|
console.log('✓ 工具已正确实现,可以使用!\n');
|
|
|
|
console.log('推荐测试卡号(任选一张):\n');
|
|
newCards.forEach((card, i) => {
|
|
console.log(`${i + 1}. ${card}`);
|
|
});
|
|
} else {
|
|
console.log('✗ 存在不符合规律的卡号,需要修复');
|
|
}
|