encode method
Encode into bytes.
Implementation
@override
Uint8List encode() {
final bytes = <int>[];
// The "openssh-key-v1" null terminated
// ignore: cascade_invocations
bytes
..addAll(latin1.encode(magicVersionId))
..add(0); // null terminate
// Values with a length before them:
// ignore: cascade_invocations
bytes.addAll(BinaryLengthValue.encode([
BinaryLengthValue.fromString(cipherName),
BinaryLengthValue.fromString(kdfName),
BinaryLengthValue(kdf)
]));
// ignore: cascade_invocations
bytes.addAll(Uint8List.fromList([0, 0, 0, 1])); // number of keys: no length
// Keys: also values with a length before them
// ignore: cascade_invocations
bytes.addAll(BinaryLengthValue.encode([
BinaryLengthValue(publicKeyBytes),
BinaryLengthValue(privateKeyBytes)
]));
final result = Uint8List.fromList(bytes);
return result;
}