Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Help in masking password

by geethadilip (Initiate)
on Aug 15, 2006 at 15:51 UTC ( #567492=perlquestion: print w/replies, xml ) Need Help??

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

Hi All,

I'm new to this group,i have a query,the query is in my module there are different skeleton files which is used as target to call the other perl files ,the skeleton files is just a simple mkskel file(it looks similar to perl not sure which language ).

So when the corresponding target is called ,while compliling it calls the exported variables ,out of this exported variables ,the password is alos one such factor which is also getting displayed, which is highly unacceptable i want that particular variable should be masked ,how to do that.

In simple words ,if u see the code which is mentioned below,while cmpliling it displays the variables such as DB2_NAME,DB@_USERNAME...out of this idon't want the variable DB2_PASSWORD should not be displayed.

${Main_file /sub_file.perl -s bnd -r ${DB2_NAME} -u ${DB2_ USERNAME} -p ${DB2_PASSWORD} \

Replies are listed 'Best First'.
Re: Help in masking password
by Tanktalus (Canon) on Aug 15, 2006 at 17:58 UTC

    One way is to put it in your environment. If you're in a shell script, export (bourne-shell and derivitives) or setenv (C shell and derivitives) should help there. If it's a perl script calling another perl script, see the %ENV hash.

    Another way, since this is DB2, is to discard the password and username altogether. Run it as a user who has the authority to do what you need, and no password is required. DB2 will use the OS authentication to confirm who you are. This is how I've generally done this - avoids all the hassles of dealing with passwords in plain-text perl code.

Re: Help in masking password
by gasho (Beadle) on Aug 15, 2006 at 17:46 UTC
    Try this
    ###################################################################### +####### # This functions will store and retreive pass using crypt # Usage: =begin COMMENT $LocationOfTheScriptsDirectory='D:\InstallV3'; $passFile="$LocationOfTheScriptsDirectory\\as.txt"; $passEncrFile="$LocationOfTheScriptsDirectory\\ass.txt"; $key='test'; $pas='zest'; storePass($key,$pas,$passEncrFile,$passFile); $P=retreivePass($key,$passEncrFile); print $P; $WhoAmI=`whoami`; @SystemUserid=split(/\\/,$WhoAmI); $MyUserId=trim($SystemUserid[1]); #crypt -e myuserid < MyPass.txt > mpcr.txt $MP=`crypt -d $MyUserId < mpcr.txt`; $MyPassword=trim($MP); =end COMMENT =cut sub storePass #($Key,$Pass,$passEncrFile,$passFile) { my($Key,$Pass,$passEncrFile,$passFile)= @_; my($enc); open (OFH,">$passFile") || die "Can't open OFH file: \n"; print OFH $Pass; close OFH; #create $passEncrFile that will hold pass encrypted value $enc=`crypt -e $Key < $passFile > $passEncrFile`; #remove passFile unlink ($passFile); } sub retreivePass #($Key,$passEncrFile) { my($Key,$passEncrFile)= @_; my($cr,$myPassword); $cr=`crypt -d $Key < $passEncrFile`; $myPassword=trim($cr); return $myPassword; }
    (: Life is short enjoy it :)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://567492]
Approved by Arunbear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (3)
As of 2023-06-10 00:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How often do you go to conferences?






    Results (36 votes). Check out past polls.

    Notices?