Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Web fl admin milestone to create #1

Open
dd84ai opened this issue Feb 1, 2025 · 0 comments
Open

Web fl admin milestone to create #1

dd84ai opened this issue Feb 1, 2025 · 0 comments

Comments

@dd84ai
Copy link
Member

dd84ai commented Feb 1, 2025

Copy of data in https://github.com/darklab8/fl-server-vanilla/tree/master/docs/fladmin_inspiration

Relevant information for inspiration

using System;
using System.IO;
namespace LibreLancer.Data.Save
{
    public static class FlCodec
    {
        const uint FLS1 = 0x31534C46; //FLS1 string

        public static byte[] DecodeBytes(byte[] input)
        {
            if (input.Length < 4)
                return input;
            if (BitConverter.ToUInt32(input, 0) == FLS1)
                return Crypt(input, 4, input.Length - 4);
            return input;
        }

        public static byte[] ReadFile(string file) =>
            DecodeBytes(File.ReadAllBytes(file));

        public static void WriteFile(byte[] bytes, string file)
        {
            using(var writer = new BinaryWriter(File.Create(file)))
            {
                writer.Write(FLS1);
                writer.Write(Crypt(bytes, 0, bytes.Length));
            }
        }

        static readonly byte[] gene = new byte[] { (byte)'G', (byte)'e', (byte)'n', (byte)'e' };
        static byte[] Crypt(byte[] buf, int offset, int len)
        {
            byte[] output = new byte[len];
            for (int i = 0; i < len; i++)
                output[i] = (byte)(buf[offset + i] ^ (byte)((gene[i & 3] + i) | 0x80));
            return output;
        }
    }
}

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

1 participant