// // LstDecryptor.cs // // Copyright (c) František Boháček. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System.Buffers.Binary; using Remora.Results; namespace NosSmooth.Data.NOSFiles.Decryptors; /// public class LstDecryptor : IDecryptor { /// public Result Decrypt(ReadOnlySpan data) { if (data.Length == 0) { return Array.Empty(); } var output = new MemoryStream(); var linesCount = BinaryPrimitives.ReadInt32LittleEndian(data); data = data.Slice(4); for (var i = 0; i < linesCount; i++) { int lineLength = BinaryPrimitives.ReadInt32LittleEndian(data); data = data.Slice(4); ReadOnlySpan line = data.Slice(0, lineLength); data = data.Slice(lineLength); foreach (var c in line) { output.WriteByte((byte)(c ^ 0x1)); } output.WriteByte((byte)'\n'); } return output.ToArray(); } }