开发者

Credit Card Scrubber/Sanitizer library in Java

I've tried searching to see if something like this exists, but I wasn't able to find anything. I was looking for something that is able to search for credit card numbers and CVV2 codes in a body of text (string), and sanitize/scrub it (replace it with x's for example). I wanted to see if something like this already exists before trying to roll my o开发者_StackOverflow社区wn (I was going to use the information here).


I have no out-of-the-box solution for you, but if you want to take the route of regular expressions, you can identify credit card numbers with the regular expression included in the OWASP ESAPI validation properties:

^(\\d{4}[- ]?){3}\\d{4}$

You have to take a closer look if it works for all cases you will run into. If the number is somehow malformed, the regular expression will fail of course.

A CVV2 number is just 3 or 4 digit number. You can also replace all of them with x's, but you will have a high rate of false positives. If the text you want to sanitize as some structure that helps you to find the credit card numbers and CVV2s, you can create something more elegant.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜