-
-
Save rab/430629 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def mask(x)y=x.dup;y[6...-4]=y[6...-4].gsub(/./,'*');y end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ ['Discover', '6011111111111117', '601111******1117'], | |
['MasterCard', '5555555555554444', '555555******4444'], | |
['Visa', '4012888888881881', '401288******1881'], | |
['American Express', '378282246310005', '378282*****0005' ], | |
['Diners Club', '30569309025904', '305693****5904' ], | |
].each do |card, number, masked| | |
actual = mask(number) | |
next if actual == masked | |
puts "%20s %-20s => %-20s (expected %s)"%[card,number,actual,masked] | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment