Skip to content

Latest commit

 

History

History
50 lines (34 loc) · 1.13 KB

README.md

File metadata and controls

50 lines (34 loc) · 1.13 KB

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'