Brovnik has asked for the wisdom of the Perl Monks concerning the following question:
I have tried 2 approaches, and both work (i.e. I haven't been able to break them) , but I'd like any comments on whether one is "more secure" than the other.
Method 1 - enclose package in a scope
{ # Hide everything package Crypt::Password; our @EXPORT_OK = (public_func); my $secret_var1 = 0; my $secret_hash = (); sub private_func () sub public_func () }
Method 2 - store variables in pointer (could be an object);
The second approach passes a ref to all of the variables as needed, but this can become a pain.package Crypt::Password; our @EXPORT_OK = (public_func); sub private_func () sub public_func ( my $p; $p->{secret_var1} = 0; $p->{secret_hash) = (); private_func($p); # could be bless ($p,"Crypt::Password") and then # $p->private_func(); )
P.S. I'll be posting the code soon. It allows interactive retrival of passwords
from a database. Used for personal storage of e.g. website logins,
or can be used by multiple users (e.g. sysadms) to store passwords to multiple hosts.
--
Brovnik
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Hiding my variables
by Aighearach (Initiate) on Jun 15, 2001 at 15:43 UTC | |
|
Re: Hiding my variables
by btrott (Parson) on Jun 15, 2001 at 21:17 UTC | |
|
Re: Hiding my variables
by larryk (Friar) on Jun 15, 2001 at 15:41 UTC |