Project

pan

0.0
No release in over 3 years
Low commit activity in last 3 years
A credit card number AKA Primary Account Number (PAN) often needs to be masked or truncated, that is, have "enough" digits made unreadable.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

>= 2.0.0
 Project Readme

pan

Cares about PANs (Primary Account Number).

Build status Code Climate License

Examples

require 'pan'

pan = '1234567890123456'

Pan.mask(pan)
#=> '123456******3456'

pan
#=> '1234567890123456'

Pan.truncate(pan)
#=> '123456******3456'

pan
#=> '123456******3456'

(Yes, that's the difference between masking and truncating a PAN in PCI DSS terminology.)

You may decide how much to mask (or truncate) and the character(s) that the digits are replaced with:

Pan.template = [0, 'x', 4]

Pan.mask('1234567890123456')
#=> 'xxxxxxxxxxxx3456'
pan = '1234567890123456'

Pan.mask(pan, template: [4, 'X', 4])
#=> '1234XXXXXXXX3456'

Pan.truncate(pan, template: [6, '*', 4]); pan
#=> '123456******3456'