From d9c27d75c39cfcdff59eecc8b6ec77b8b077a325 Mon Sep 17 00:00:00 2001 From: Herbert Poul Date: Sun, 19 Apr 2020 21:37:41 +0200 Subject: [PATCH] add argument to decrypt with keyfile to command line script --- bin/kdbx.dart | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/bin/kdbx.dart b/bin/kdbx.dart index eb49717..caf1273 100644 --- a/bin/kdbx.dart +++ b/bin/kdbx.dart @@ -65,6 +65,11 @@ abstract class KdbxFileCommand extends Command { help: 'Input kdbx file', valueHelp: 'foo.kdbx', ); + argParser.addOption( + 'keyfile', + abbr: 'k', + help: 'Keyfile for decryption', + ); argParser.addOption( 'password', abbr: 'p', @@ -83,8 +88,14 @@ abstract class KdbxFileCommand extends Command { final password = argResults['password'] as String ?? prompts.get('Password for $inputFile', conceal: true, validate: (str) => str.isNotEmpty); - final file = await KdbxFormat(Argon2Test()) - .read(bytes, Credentials(ProtectedValue.fromString(password))); + final keyFile = argResults['keyfile'] as String; + final keyFileData = + keyFile == null ? null : await File(keyFile).readAsBytes(); + ; + final file = await KdbxFormat(Argon2Test()).read( + bytes, + Credentials.composite(ProtectedValue.fromString(password), keyFileData), + ); return runWithFile(file); }