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', help: 'Input kdbx file',
valueHelp: 'foo.kdbx', valueHelp: 'foo.kdbx',
); );
argParser.addOption(
'keyfile',
abbr: 'k',
help: 'Keyfile for decryption',
);
argParser.addOption( argParser.addOption(
'password', 'password',
abbr: 'p', abbr: 'p',
@ -83,8 +88,14 @@ abstract class KdbxFileCommand extends Command<void> {
final password = argResults['password'] as String ?? final password = argResults['password'] as String ??
prompts.get('Password for $inputFile', prompts.get('Password for $inputFile',
conceal: true, validate: (str) => str.isNotEmpty); conceal: true, validate: (str) => str.isNotEmpty);
final file = await KdbxFormat(Argon2Test()) final keyFile = argResults['keyfile'] as String;
.read(bytes, Credentials(ProtectedValue.fromString(password))); 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); return runWithFile(file);
} }

Loading…
Cancel
Save