- 浏览: 257778 次
- 性别:
- 来自: 多伦多
文章分类
- 全部博客 (127)
- Java 基础 (46)
- Java EE (3)
- Clouds (1)
- Spring 编程 (7)
- Spring Batch 编程 (1)
- Quartz 编程 (9)
- Seam 编程 (4)
- Hibernate 编程 (1)
- JSF 编程 (3)
- jQuery 编程 (3)
- Interview Question 汇总 (3)
- 日常应用 (3)
- Maven 编程 (2)
- WebService 编程 (10)
- Scala 编程 (5)
- Coherence 编程 (8)
- OO 编程 (1)
- Java 线程 (6)
- DB 编程 (2)
- WebService 安全 (4)
- Oracle Fusion 编程 (2)
- JavsScript/Ajax 编程 (1)
最新评论
-
chainal:
赞,说的很好
Scala 有趣的Trait -
wuliupo:
RRRR-MM-DD HH24:MI:SS
如何让Oracle SQL Developer显示的包含在日期字段中的时间 -
pengain:
...
使用Spring Roo ,感受ROR式的开发 -
zeng1990:
def getPersonInfo() = {
(&quo ...
Java 的继位人? - Scala简介 -
zeng1990:
我使用的是2.9.2版本的!
Java 的继位人? - Scala简介
/**
* Check whether a credit card number is valid or not according to the Luhn algorithm (MOD10).<br/>
* <br/>
* (Getting from http://en.wikipedia.org/wiki/Luhn_algorithm)<br/>
* 1. Counting from the check digit, which is the rightmost, and moving left, double the value of every second digit.<br/>
* 2. Sum the digits of the products together with the undoubled digits from the original number.<br/>
* 3. If the total ends in 0 (put another way, if the total modulo 10 is equal to 0), then the number
* is valid according to the Luhn formula; else it is not valid.<br/>
* <br/>
* As an illustration, if the account number is 49927398716, it will be validated as follows:<br/>
* i. Double every second digit, from the rightmost:<br/>
* (1×2) = 2, (8×2) = 16, (3×2) = 6, (2×2) = 4, (9×2) = 18<br/>
* ii. Sum all the individual digits (digits in parentheses are the products from Step 1):<br/>
* 6 + (2) + 7 + (1+6) + 9 + (6) + 7 + (4) + 9 + (1+8) + 4 = 70<br/>
* iii. Take the sum modulo 10: 70 mod 10 = 0; the account number is valid.<br/>
*
* @param num
* @return boolean true-valid; false-invalid
*/
public static boolean isValidCC(String num) {
// //Check digits
// if(!num.matches("^\\d{13,19}$"))
// return false;
//Check mod10
final int[][] sumTable = {{0,1,2,3,4,5,6,7,8,9},{0,2,4,6,8,1,3,5,7,9}};
int sum = 0, flip = 0;
for (int i = num.length() - 1; i >= 0; i--, flip++){
int n = num.charAt(i) - '0';
if (n < 0 || n > 9)
return false;
sum += sumTable[flip & 0x1][n];
}
return (sum == 0) ? false : (sum % 10 == 0);
}
/**
* Check whether a credit card number is valid or not according to the Luhn algorithm (MOD10).<br/>
* Used switch to double specified value.<br/>
*
* @param number
* @return
*/
public static boolean isValidCC1(String number) {
int sum = 0;
int mul = 1;
for (int i = number.length() - 1; i >= 0; i--) {
int n = number.charAt(i) - '0';
if (n < 0 || n > 9)
return false;
n *= (mul == 1) ? mul++ : mul--;
sum += (n>9 ? n-9 : n);
}
return (sum == 0) ? false : (sum % 10 == 0);
}
/**
* Check whether a credit card number is valid or not according to the Luhn algorithm (MOD10).<br/>
* Used position to double specified value.<br/>
*
* @param number
* @return
*/
public static boolean isValidCC2(String number) {
int sum = 0;
for (int i = number.length() - 1; i >= 0; i--) {
int n = number.charAt(i) - '0';
if (n < 0 || n > 9)
return false;
if ((number.length()-i)%2 == 0)
n *= 2;
sum += (n>9 ? n-9 : n);
}
return (sum == 0) ? false : (sum % 10 == 0);
}
/**
* Check whether a credit card number is valid or not according to the Luhn algorithm (MOD10).<br/>
* Used AND and XOR to double specified value.<br/>
* @param number
* @return
*/
public static boolean isValidCC3(String number) {
int digits = number.length();
int oddOrEven = digits & 1;
long sum = 0;
for (int i = 0; i < digits; i++) {
int n = number.charAt(i) - '0';
if (n < 0 || n > 9)
return false;
if (((i & 1) ^ oddOrEven) == 0)
n *= 2;
sum += (n>9 ? n-9 : n);
}
return (sum == 0) ? false : (sum % 10 == 0);
}
/**
* Check whether a credit card number is valid or not according to the Luhn algorithm (MOD10).<br/>
* Used a variable as switch to double specified value.
* @param number
* @return
*/
private static boolean isValidCC4(String number) {
int sum = 0;
boolean alternate = false;
for (int i = number.length() - 1; i >= 0; i--) {
int n = Integer.parseInt(number.substring(i, i + 1)); //May throw out a runtime exception
if (n < 0 || n > 9)
return false;
if (alternate)
n *= 2;
sum += (n>9 ? n%10 + 1 : n);
alternate = !alternate;
}
return (sum == 0) ? false : (sum % 10 == 0);
}
信用卡前缀及校验规则
CARD TYPE
Prefix
Length
Check digit
algorithm
MASTERCARD
51-55
16
mod 10
VISA
4
13, 16
mod 10
AMEX
34
3715
mod 10
Diners Club/
Carte Blanche300-305
36
3814
mod 10
Discover
6011
16
mod 10
enRoute
2014
214915
any
JCB
3
16
mod 10
JCB
2131
180015
mod 10
发表评论
-
设计模式之事务处理
2010-11-25 07:36 886转自 http://www.blogjava.net/kill ... -
设计自己的MVC框架(1)
2010-11-25 07:27 1221转自 http://www.blogjava.net/ ... -
设计自己的MVC框架(2)
2010-11-25 07:24 1148转自 http://www.blogjava.ne ... -
使用Annotation设计持久层
2010-11-25 06:59 914(From http://www.blogjava. ... -
Jakarta Commons StringUtils类使用
2010-11-25 06:58 908转自http://www.blogjava.net/ ... -
Jakarta Commons ArrayUtils类使用
2010-11-25 06:57 1101转自http://www.blogjava.net/ ... -
Reflection的三个动态性质
2010-11-25 06:56 983转自http://www.blogjava. ... -
用commons.fileupload实现文件的上传和下载
2010-11-25 06:55 1360转自http://www.blogjav ... -
JAVA基础:共享内存在Java中的实现和应用
2010-11-25 06:54 849(转自 http://www.bu ... -
JAVA变量类型之间的相互转换
2010-11-25 06:52 872(转自 http://www.builder.c ... -
优秀Java程序员必须了解的GC工作原理
2010-11-25 06:52 861(转自 http://www.build ... -
几种版权信息详解
2010-11-25 06:49 1103BSD开源协议(original ... -
Java JDK 1.4 JCE Provider issue.
2010-11-25 06:48 1150Bundled JCE provider in jdk1 ... -
Why use Map.entrySet() instead of Map.keySet()?
2010-11-25 06:45 1367(From http://www.coderan ... -
如何知道方法的调用者
2010-11-25 05:57 7363转自http://hellboys.bok ... -
Java加解密的基础
2010-11-25 05:49 2796在Java的安全包中,包括了三部分内容: ... -
Java日志框架:SLF4J, Apache Common-Logging, Log4J和Logback
2010-11-25 05:47 1830Log4j Apache的一个开放源代码项目,通过 ... -
Java SE 6新特性:Instrumentation
2010-11-25 05:35 1058(转自http://baike.baidu.com ... -
JBOSS 启动 加载 过程
2010-09-11 00:26 2973(转自: http://blog.csdn.net/ylli_ ... -
JAVA性能优化—Sun Hotspot JDK JVM参数设置
2010-09-11 00:18 1149(转自: http://www.hashei.me/2009/ ...
相关推荐
11贷款预测-creditcard.csv 数据集.zip11贷款预测-creditcard.csv 数据集.zip11贷款预测-creditcard.csv 数据集.zip11贷款预测-creditcard.csv 数据集.zip11贷款预测-creditcard.csv 数据集.zip
creditcard csv - 训练集 信用卡数据 信用卡训练数据, 有兴趣的童鞋们可以下载
creditcard训练集经处理,
内含竞赛数据集creditcard.csv,简单处理imbalaced问题,采用逻辑回归算法,用度量标准进行评价。 ·Jupyter notebook
交易数据异常检测--creditcard.zip
此文件是Java中的credit card class, 其中包含了 卡号鉴别器。
cret edit call me call met
可以验证各种信用卡的有效性,如Visa,MasterCard……
creditcard.js, 在JavaScript中,一个简单的信用卡验证库 creditcard.js JavaScript中一个简单的信用卡验证库。安装你可以下载zip文件,或者使用NPM和 Bower 。 NPM$ npm install --save creditcard.js
一个功能强大的CreditCard验证码控件源码及例子CreditCardValidator_v3_source_Example。
信用卡欺诈检测数据
Credit card fraud 数据集包含了 2013 年九月欧洲的信用卡持有者的交易记录。交易次数共有 284807 次,其中的 492 次为诈骗交易。该数据集多用于金融领域
Credit Card beta1.0.20100115信用卡基础知识 银行系统开发,银行业务知识整理完成 银行业务知识汇编全稿
data science about creditcard
信用卡卡号识别,基于模板匹配的方式。
credit card fraud detection
In the present, I focus on security protocols in the electronic payment, particularly electronic security protocol set developed by a group of large credit card companies like Visa, MasterCard and ...
SAS 信用卡 UCI数据 数据集信息 ... 内容 ...LIMIT_BAL:以新台币计的给定信用额度(包括个人和家庭/辅助信用额) ...教育程度:(1 =研究生院,2 =大学,3 =高中,4 =其他,5 =未知,6 =未知) ...BILL_AMT2:2005年