public class Luhn extends Object
Constructor and Description |
---|
Luhn() |
Modifier and Type | Method and Description |
---|---|
static boolean |
check(String strWithCheckDigit)
校验字符串
|
static int |
getCheckDigit(String str,
boolean withCheckDigit)
计算校验位数字
忽略已有的校验位数字,根据前N位计算最后一位校验位数字 |
public static boolean check(String strWithCheckDigit)
strWithCheckDigit
- 含校验数字的字符串IllegalArgumentException
- 如果字符串为空或不是8~19位的数字public static int getCheckDigit(String str, boolean withCheckDigit)
str
- 被检查的数字withCheckDigit
- 是否含有校验位Copyright © 2025. All rights reserved.