Geekpedia Programming Tutorials









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.)

On Wednesday, April 23rd 2008 at 01:48 AM
By Andrei Pociu (View Profile)
-----   (Rated 0 with 0 votes)
Contextual Ads
More Ruby Resources
Advertisement
  1. def HideCCDigits(CardNum)
  2.   CardNum.sub((part = CardNum[0..-5]), '*' * part.length)
  3. end
Digg Digg It!     Del.icio.us Del.icio.us     Reddit Reddit     StumbleUpon StumbleIt     Newsvine Newsvine     Furl Furl     BlinkList BlinkList

Rate Rate this code snippet
Comment Current Comments
There are no comments.

Comment Comment on this tutorial
Name: Email:
Message:
Comment Related Source Code
There is no related code.

Comment Related Tutorials
There are no related tutorials.

Jobs Ruby Job Search
My skills include:
Enter a City:

Select a State:


Advanced Search >>
Latest Tech Bargains

Advertisement

Free Magazine Subscriptions

Today's Pictures

Today's Video

Other Resources

Latest Downloads

Latest Icons