note

 view release on metacpan or  search on metacpan

lib/NOTEDB/pwsafe3.pm  view on Meta::CPAN

  my ($this, $num) = @_;
  return $this->{numuuid}->{$num};
}

sub _getpass {
  #
  # We're doing this here ourselfes
  # because the note way of handling encryption
  # doesn't work with pwsafe3, we can't hold a cipher
  # structure in memory, because pwsafe3 handles this
  # itself.
  # Instead we ask for the password everytime we want
  # to fetch data from the actual file OR want to write
  # to it. To minimize reads, we use caching by default.
  my($this, $prompt) = @_;

  if ($this->{key}) {
    return $this->{key};
  }
  else {
    my $key;
    print STDERR $prompt ? $prompt : "pwsafe password: ";
    eval {
      local($|) = 1;
      local(*TTY);
      open(TTY,"/dev/tty") or die "No /dev/tty!";
      system ("stty -echo </dev/tty") and die "stty failed!";
      chomp($key = <TTY>);
      print STDERR "\r\n";
      system ("stty echo </dev/tty") and die "stty failed!";
      close(TTY);
    };
    if ($@) {
      $key = <>;
    }
    if ($this->{keepkey}) {
      $this->{key} = $key;
    }
    return $key;
  }
}

1; # keep this!

__END__

=head1 NAME

NOTEDB::pwsafe3 - module lib for accessing a notedb from perl

=head1 SYNOPSIS

	# include the module
	use NOTEDB;

	# create a new NOTEDB object
	$db = new NOTEDB("text", "/home/tom/.notedb", 4096, 24);

	# decide to use encryption
	# $key is the cipher to use for encryption
	# $method must be either Crypt::IDEA or Crypt::DES
	# you need Crypt::CBC, Crypt::IDEA and Crypt::DES to have installed.
	$db->use_crypt($key,$method);

	# do not use encryption
	# this is the default
	$db->no_crypt;

	# get a single note
	($note, $date) = $db->get_single(1);

	# search for a certain note 
	%matching_notes = $db->get_search("somewhat");
	# format of returned hash:
	#$matching_notes{$numberofnote}->{'note' => 'something', 'date' => '23.12.2000 10:33:02'}

	# get all existing notes
	%all_notes = $db->get_all();
	# format of returns hash like the one from get_search above

	# get the next noteid available
	$next_num = $db->get_nextnum();

	# modify a certain note
	$db->set_edit(1, "any text", "23.12.2000 10:33:02");

	# create a new note
	$db->set_new(5, "any new text", "23.12.2000 10:33:02");

	# delete a certain note
	$db->set_del(5);

        # turn on encryption. CryptMethod must be IDEA, DES or BLOWFISH
        $db->use_crypt("passphrase", "CryptMethod");

        # turn off encryption. This is the default.
        $db->no_crypt();


=head1 DESCRIPTION

You can use this module for accessing a note database. This backend uses
a text file for storage and Config::General for accessing the file.

Currently, NOTEDB module is only used by note itself. But feel free to use it
within your own project! Perhaps someone want to implement a web interface to
note...

=head1 USAGE

please see the section SYNOPSIS, it says it all.

=head1 AUTHOR

Thomas Linden <tom AT linden DOT at>


=cut




( run in 1.265 second using v1.01-cache-2.11-cpan-39bf76dae61 )