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); }