Browse Source

add argument to decrypt with keyfile to command line script

remove-cryptography-dependency
Herbert Poul 5 years ago
parent
commit
d9c27d75c3
  1. 15
      bin/kdbx.dart

15
bin/kdbx.dart

@ -65,6 +65,11 @@ abstract class KdbxFileCommand extends Command<void> {
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<void> {
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);
}

Loading…
Cancel
Save