Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Debug values encrypt as XXXX

by sanku (Beadle)
on Jul 18, 2011 at 07:23 UTC ( #915087=perlquestion: print w/replies, xml ) Need Help??

sanku has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks, I am having a dumper value as follows
$VAR1 = { 'nodeId' => '1234', 'param' => { 'CardNumber' => '0000000000000000', 'Y' => '2000', 'M' => '06', 'C' => '000', }, 'cont' => '0' };
And i need to chage the CardNumber value as 'XXXXXXXXXXXXXXXX' only during the printing of debug.

Replies are listed 'Best First'.
Re: Debug values encrypt as XXXX
by chrestomanci (Priest) on Jul 18, 2011 at 09:37 UTC

    There are special configuration varables in the Data::Dumper namespace that you can set to control how object are dumped. My advice would be to create a dump filter, (see: or to make use of $Data::Dumper::Freezer

    With $Data::Dumper::Freezer you provide the name of a class method that Data::Dumper will attempt to call on each object it dumps, and if that method exists, the object returned will be dumped instead of the original object, so for your class containing credit card numbers you could provide a hide_secrets() method that blanks out or encypts the secrets. For other classes there will be no such method, so they will be dumped as they are.

Re: Debug values encrypt as XXXX
by Anonymous Monk on Jul 18, 2011 at 11:39 UTC

    Probably the most important consideration for you is to be sure that the debug output cannot somehow wind up on somebody’s web page.

Re: Debug values encrypt as XXXX
by duelafn (Parson) on Jul 19, 2011 at 17:43 UTC

    I've posted RFC: SecureString - Obfuscated / masked strings exept when you need them in response to this post. Hopefully either this post, or that post will yield some responses that are useful to you. Unfortunately, the module I threw togeter for that post is too immature (and totally untested) for me to reccommend at this time. In fact, I would even reccommend against using the module as posted - relying on something so immature is a bad idea in my book.

    Good Day,

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://915087]
Approved by Corion
Front-paged by Corion
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2021-12-07 12:19 GMT
Find Nodes?
    Voting Booth?
    R or B?

    Results (33 votes). Check out past polls.