KeepassX format implementation in pure dart.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
789 B

import 'package:meta/meta.dart';
import 'package:uuid/uuid.dart';
import 'package:xml/xml.dart';
class KdbxTimes {
KdbxTimes.read(this.node);
XmlElement node;
DateTime get creationTime => _readTime('CreationTime');
DateTime _readTime(String nodeName) =>
DateTime.parse(node.findElements(nodeName).single.text);
}
abstract class KdbxObject {
KdbxObject.create(String nodeName)
: uuid = Uuid().v4(),
node = XmlElement(XmlName(nodeName));
KdbxObject.read(this.node) {
uuid = node.findElements('UUID').single.text;
}
final XmlElement node;
String uuid;
@protected
String text(String nodeName) => _opt(nodeName)?.text;
XmlElement _opt(String nodeName) =>
node.findElements(nodeName).singleWhere((x) => true, orElse: () => null);
}