|
|
@ -9,10 +9,14 @@ import 'package:quiver/core.dart'; |
|
|
|
import 'package:xml/xml.dart'; |
|
|
|
import 'package:xml/xml.dart'; |
|
|
|
|
|
|
|
|
|
|
|
class KdbxBinary { |
|
|
|
class KdbxBinary { |
|
|
|
KdbxBinary({this.isInline, this.isProtected, this.value}); |
|
|
|
KdbxBinary({ |
|
|
|
final bool? isInline; |
|
|
|
required this.isInline, |
|
|
|
final bool? isProtected; |
|
|
|
required this.isProtected, |
|
|
|
final Uint8List? value; |
|
|
|
required this.value, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
final bool isInline; |
|
|
|
|
|
|
|
final bool isProtected; |
|
|
|
|
|
|
|
final Uint8List value; |
|
|
|
int? _valueHashCode; |
|
|
|
int? _valueHashCode; |
|
|
|
|
|
|
|
|
|
|
|
static KdbxBinary readBinaryInnerHeader(InnerHeaderField field) { |
|
|
|
static KdbxBinary readBinaryInnerHeader(InnerHeaderField field) { |
|
|
@ -26,16 +30,16 @@ class KdbxBinary { |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int get valueHashCode => _valueHashCode ??= hashObjects(value!); |
|
|
|
int get valueHashCode => _valueHashCode ??= hashObjects(value); |
|
|
|
|
|
|
|
|
|
|
|
bool valueEqual(KdbxBinary other) => |
|
|
|
bool valueEqual(KdbxBinary other) => |
|
|
|
valueHashCode == other.valueHashCode && ByteUtils.eq(value!, value!); |
|
|
|
valueHashCode == other.valueHashCode && ByteUtils.eq(value, other.value); |
|
|
|
|
|
|
|
|
|
|
|
InnerHeaderField writeToInnerHeader() { |
|
|
|
InnerHeaderField writeToInnerHeader() { |
|
|
|
final writer = WriterHelper(); |
|
|
|
final writer = WriterHelper(); |
|
|
|
final flags = isProtected! ? 0x01 : 0x00; |
|
|
|
final flags = isProtected ? 0x01 : 0x00; |
|
|
|
writer.writeUint8(flags); |
|
|
|
writer.writeUint8(flags); |
|
|
|
writer.writeBytes(value!); |
|
|
|
writer.writeBytes(value); |
|
|
|
return InnerHeaderField( |
|
|
|
return InnerHeaderField( |
|
|
|
InnerHeaderFields.Binary, writer.output.takeBytes()); |
|
|
|
InnerHeaderFields.Binary, writer.output.takeBytes()); |
|
|
|
} |
|
|
|
} |
|
|
@ -56,8 +60,8 @@ class KdbxBinary { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void saveToXml(XmlElement valueNode) { |
|
|
|
void saveToXml(XmlElement valueNode) { |
|
|
|
final content = base64.encode(gzip.encode(value!)); |
|
|
|
final content = base64.encode(gzip.encode(value)); |
|
|
|
valueNode.addAttributeBool(KdbxXml.ATTR_PROTECTED, isProtected!); |
|
|
|
valueNode.addAttributeBool(KdbxXml.ATTR_PROTECTED, isProtected); |
|
|
|
valueNode.addAttributeBool(KdbxXml.ATTR_COMPRESSED, true); |
|
|
|
valueNode.addAttributeBool(KdbxXml.ATTR_COMPRESSED, true); |
|
|
|
valueNode.children.add(XmlText(content)); |
|
|
|
valueNode.children.add(XmlText(content)); |
|
|
|
} |
|
|
|
} |
|
|
|