diff options
author | Daniel Friesel <derf@finalrewind.org> | 2011-02-12 23:44:32 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2011-02-12 23:44:32 +0100 |
commit | f97dc34bd88bae0cdc41a827d80f998849824a01 (patch) | |
tree | f908011408c57c8b7021a69536556fde022abefb /bin/raps2 | |
parent | c83725c4fb7ee84b234d3faeffb03ba7c94c2e11 (diff) |
Add info cmd, put password into x clipboard for raps2 get
Diffstat (limited to 'bin/raps2')
-rwxr-xr-x | bin/raps2 | 30 |
1 files changed, 27 insertions, 3 deletions
@@ -51,6 +51,9 @@ sub cmd_add { $state{'login'} = read_input( prefix => 'Login' ); + $state{'extra'} = read_input( + prefix => 'Extra' + ); $pass = read_input( prefix => 'Password', invisible => 1, @@ -79,11 +82,23 @@ sub cmd_get { $cipher = setup_cipher($password); + to_clipboard($cipher->decrypt_hex($state{'hash'})); +} + +sub cmd_info { + my ($name) = @_; + my $store = get_xdg_data_home() . "/${name}"; + + if (not -e $store) { + die("No such password\n"); + } + + load_state_from($store); + printf( - "URL : %s\nLogin : %s\nPassword: %s\n", + "URL : %s\nLogin: %s\n", $state{'url'}, - $state{'login'}, - $cipher->decrypt_hex($state{'hash'}), + $state{'login'} ); } @@ -218,6 +233,14 @@ sub setup_cipher { return Crypt::CBC->new(-cipher => $eksblowfish); } +sub to_clipboard { + my ($pw) = @_; + + open(my $clipboard, '|-', 'xclip -l 1'); + print $clipboard $pw; + close($clipboard); +} + sub read_input { my %opts = @_; my ($prefix, $invisible, $verify) @@ -265,6 +288,7 @@ create_dot_dirs(); given ($action) { when ('add') { cmd_add(@args) } when ('get') { cmd_get(@args) } + when ('info') { cmd_info(@args) } } __END__ |