=================================================================== RCS file: /cvs/palm/Palm-Keyring/lib/Palm/Keyring.pm,v retrieving revision 1.23 retrieving revision 1.26 diff -u -r1.23 -r1.26 --- palm/Palm-Keyring/lib/Palm/Keyring.pm 2007/02/02 01:51:46 1.23 +++ palm/Palm-Keyring/lib/Palm/Keyring.pm 2007/02/06 02:58:50 1.26 @@ -1,6 +1,6 @@ package Palm::Keyring; -# $RedRiver: Keyring.pm,v 1.22 2007/02/01 01:56:11 andrew Exp $ +# $RedRiver: Keyring.pm,v 1.25 2007/02/03 01:12:21 andrew Exp $ # # Perl class for dealing with Keyring for Palm OS databases. # @@ -14,18 +14,16 @@ use Digest::MD5 qw(md5); use Crypt::DES; -use Readonly; -Readonly my $ENCRYPT => 1; -Readonly my $DECRYPT => 0; -Readonly my $MD5_CBLOCK => 64; -Readonly my $kSalt_Size => 4; -Readonly my $EMPTY => q{}; -Readonly my $SPACE => q{ }; -Readonly my $NULL => chr 0; +my $ENCRYPT = 1; +my $DECRYPT = 0; +my $MD5_CBLOCK = 64; +my $kSalt_Size = 4; +my $EMPTY = q{}; +my $SPACE = q{ }; +my $NULL = chr 0; -# One liner, to allow MakeMaker to work. -our $VERSION = 0.92; +our $VERSION = 0.94; sub new { my $classname = shift; @@ -250,9 +248,14 @@ sub Password { my $self = shift; - my $pass = shift || $self->{'password'}; + my $pass = shift; my $new_pass = shift; + if (! $pass) { + delete $self->{password}; + return 1; + } + if (! exists $self->{'records'}) { # Give the PDB the first record that will hold the encrypted password $self->{'records'} = [ $self->new_Record ]; @@ -491,14 +494,17 @@ Use this method if you're creating a Keyring PDB from scratch otherwise you can just use Palm::PDB::new() before calling Load(). +If you pass in a password, it will initalize the first record with the encrypted +password. + =head2 Encrypt - $pdb->Encrypt($rec, $acct, [$password]); + $pdb->Encrypt($rec, $acct[, $password]); Encrypts an account into a record, either with the password previously used, or with a password that is passed. -$rec is a record from $pdb->{'records'} or a newly generated record. +$rec is a record from $pdb->{'records'} or a new_Record(). $acct is a hashref in the format below. my $acct = { @@ -514,12 +520,12 @@ }; If you have changed anything other than the lastchange, or don't pass in a -lastchange record, Encrypt() will generate a new lastchange for you. +lastchange key, Encrypt() will generate a new lastchange date for you. If you pass in a lastchange field that is different than the one in the record, it will honor what you passed in. -It also only uses the $acct->{'name'} if there is not already a $rec->{'name'}. +Encrypt() only uses the $acct->{'name'} if there is not already a $rec->{'name'}. =head2 Decrypt @@ -546,8 +552,7 @@ called new(), you only need to pass one password and it will set that as the password. -If nothing is passed, and there has been a password used before, -it just verifies that the password was correct. +If nothing is passed, it forgets the password that it was remembering. =head1 DEPENDENCIES @@ -559,9 +564,22 @@ Readonly +=head1 THANKS + +I would like to thank the helpful Perlmonk shigetsu who gave me some great advice +and helped me get my first module posted. L + +I would also like to thank +Johan Vromans +Ejvromans@squirrel.nlE -- +L. +He had his own Palm::KeyRing module that he posted a couple of days before +mine was ready and he was kind enough to let me have the namespace as well +as giving me some very helpful hints about doing a few things that I was +unsure of. He is really great. + =head1 BUGS AND LIMITATIONS -Once this module is uploaded, you can Please report any bugs or feature requests to C, or through the web interface at L. I will be notified, and then you'll automatically be @@ -586,3 +604,6 @@ The Keyring for Palm OS website: L + +Johan Vromans also has a wxkeyring app that now uses this module, available +from his website at L