using System.Text;

namespace SharpChat;
public static class ByteArrayExtensions {
    public static string GetUtf8String(this byte[] buffer) {
        return Encoding.UTF8.GetString(buffer);
    }

    public static bool SlowEquals(this byte[] buffer, byte[] other) {
        if(buffer.Length != other.Length)
            return false;

        int i = 0;
        int result = 0;
        while(i < buffer.Length) {
            result |= buffer[i] ^ other[i];
            ++i;
        }

        return result == 0;
    }
}