Sometimes, you might want to obscure usernames or passwords in your scripts or configuration files. (this is a bad thing, but sometimes you don't have much choice).
This snippet can help by producing an unreadale (but trivially reversible) rendering of the sensitive data, thanks to the pack() and unpack() functions...
Update: Just to make it clearer for the AM, you can never keep scripts or config files hidden from the sysadmins, no matter what. In order to get to a password, your Perl has to be able to read it. If your Perl can, so can the sysadmin on your box. What this is supposed to do, is make it easier for the sysadmin not to read your sensitive data. I agree with the false sense of security though.
Update 2: As suggested by bart, the "u" has been a bit obscured. Thanks!
Update to the Update 1: I just saw a typo. I wrote AC instead of AM. My mistake and sorry for that.
# You would use something like this to create the obscured data... perl -e 'print pack("u", "justanotherperlhacker"), "\n"' # How to access your obscured data in your script... our $LOGIN = unpack(chr(ord("a") + 19 + print ""), "5:G5S=&%N;W1H97)P9 +7)L:&%C:V5R");
In reply to Obscuring sensitive data in your scripts by fokat
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |