Mask All Credit Card Digits But Last Four

Mask All Credit Card Digits But Last Four
Mask all the credit card number digits with asterisks except the last 4, for security purposes. The function works for all types of cards (Visa, MasterCard, Amex, Discovery, etc.)
1. def HideCCDigits(CardNum)
2.   CardNum.sub((part = CardNum[0..-5]), '*' * part.length)
3. end

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top