]> Dogcows Code - chaz/p5-File-KDBX/blobdiff - lib/File/KDBX/Key.pm
Remove min_version and clean up a lot of pod
[chaz/p5-File-KDBX] / lib / File / KDBX / Key.pm
index 8fdb0ff9a88b7a43b483ff3f5ba50b1e48b585a1..b44faca9183c117e95cd70457ba03127a903485b 100644 (file)
@@ -8,14 +8,15 @@ use Devel::GlobalDestruction;
 use File::KDBX::Error;
 use File::KDBX::Safe;
 use File::KDBX::Util qw(erase);
+use Hash::Util::FieldHash qw(fieldhashes);
 use Module::Load;
 use Ref::Util qw(is_arrayref is_coderef is_hashref is_ref is_scalarref);
-use Scalar::Util qw(blessed openhandle refaddr);
+use Scalar::Util qw(blessed openhandle);
 use namespace::clean;
 
 our $VERSION = '999.999'; # VERSION
 
-my %SAFE;
+fieldhashes \my %SAFE;
 
 =method new
 
@@ -55,7 +56,10 @@ sub new {
     return $self;
 }
 
-sub DESTROY { !in_global_destruction and do { $_[0]->_clear_raw_key; erase \$_[0]->{primitive} } }
+sub DESTROY {
+    local ($., $@, $!, $^E, $?);
+    !in_global_destruction and do { $_[0]->_clear_raw_key; eval { erase \$_[0]->{primitive} } }
+}
 
 =method init
 
@@ -156,8 +160,8 @@ sub _clear_raw_key {
 
     $key = $key->hide;
 
-Put the raw key in L<File::KDBX/"Memory Protection">. Does nothing if the raw key is already in memory
-protection. Returns itself to allow method chaining.
+Put the raw key in L<memory protection|File::KDBX/"Memory Protection">. Does nothing if the raw key is already
+in memory protection. Returns itself to allow method chaining.
 
 =cut
 
@@ -191,10 +195,10 @@ Get whether or not the key's raw secret is currently in memory protection.
 
 =cut
 
-sub is_hidden { !!$SAFE{refaddr($_[0])} }
+sub is_hidden { !!$SAFE{$_[0]} }
 
-sub _safe     { $SAFE{refaddr($_[0])} }
-sub _new_safe { $SAFE{refaddr($_[0])} = File::KDBX::Safe->new }
+sub _safe     { $SAFE{$_[0]} }
+sub _new_safe { $SAFE{$_[0]} = File::KDBX::Safe->new }
 
 1;
 __END__
@@ -210,7 +214,7 @@ There are several different types of keys, each implemented as a subclass:
 
 =for :list
 * L<File::KDBX::Key::Password> - Password or passphrase, knowledge of a string of characters
-* L<File::KDBX::Key::File> - Possession of a file ("key file") with a secret.
+* L<File::KDBX::Key::File> - Possession of a file ("key file") with a secret
 * L<File::KDBX::Key::ChallengeResponse> - Possession of a device that responds correctly when challenged
 * L<File::KDBX::Key::YubiKey> - Possession of a YubiKey hardware device (a type of challenge-response)
 * L<File::KDBX::Key::Composite> - One or more keys combined as one
@@ -223,11 +227,11 @@ password key by itself. (Of course it's much better to not have any weak compone
 B<COMPATIBILITY NOTE:> Most KeePass implementations are limited in the types and numbers of keys they support.
 B<Password> keys are pretty much universally supported. B<File> keys are pretty well-supported. Many do not
 support challenge-response keys. If you are concerned about compatibility, you should stick with one of these
-configurations:
+well-supported configurations:
 
 =for :list
 * One password
 * One key file
-* One password and one key file
+* Composite of one password and one key file
 
 =cut
This page took 0.023035 seconds and 4 git commands to generate.