newone2011
asked on
Making a credit card no
I need to mask middle 6 digits of CC no which can be of length 16 or 15. Please confirm if my method id correct:
For example
5410102534567890
becomes
541010******7890
500120013001100
becomes
500120******100
public static String maskCCNo(String ccno){
int cclen = ccno.length();
int doNotMaskStartLen = 6;
int doNotMaskEndLen = 4;
int masklen = cclen-(doNotMaskStartLen+d oNotMaskEn dLen) ;
StringBuffer maskedBuf = new StringBuffer(ccnum.substri ng(0,start len));
for(int i=0;i<masklen;i++) {
maskedBuf.append('*');
}
maskedbuf.append(ccnum.sub string(sta rtlen+mask len, cclen));
String maskCC = maskedbuf.toString();
return maskCC;
}
5410102534567890
541010******7890
500120013001100
500120******100
For example
5410102534567890
becomes
541010******7890
500120013001100
becomes
500120******100
public static String maskCCNo(String ccno){
int cclen = ccno.length();
int doNotMaskStartLen = 6;
int doNotMaskEndLen = 4;
int masklen = cclen-(doNotMaskStartLen+d
StringBuffer maskedBuf = new StringBuffer(ccnum.substri
for(int i=0;i<masklen;i++) {
maskedBuf.append('*');
}
maskedbuf.append(ccnum.sub
String maskCC = maskedbuf.toString();
return maskCC;
}
5410102534567890
541010******7890
500120013001100
500120******100
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER