System.Collections.Generic.List.Add(byte)

Here are the examples of the csharp api System.Collections.Generic.List.Add(byte) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

1493 Examples 7

19 Source : Form1.cs
with Apache License 2.0
from 1694439208

private void button5_Click(object sender, EventArgs e)
        {
            byte[] jmp_inst =
            {
                233,0,0,0,0,//JMP Address
            };
            int Method = NativeAPI.GetMethodPTR(typeof(WeChetHook), "Callback");
            textBox3.Text = (3212659 + int.Parse(label1.Text)).ToString();

            List<byte> byteSource = new List<byte>();
            byteSource.AddRange(new byte[] { 199, 134, 236, 2, 0, 0 });//mov dword [esi+0x000002EC],
            byteSource.AddRange(BitConverter.GetBytes(int.Parse(textBox3.Text) + 5));//0x00000000  把hook的后五个字节地址压进寄存器
            byteSource.AddRange(jmp_inst);//让他跳到跳板函数
            //这部分根据实际情况填写
            byteSource.Add(185);//补充替换的汇编指令
            byteSource.AddRange(BitConverter.GetBytes(int.Parse(label1.Text) + 19255272));//补充替换的汇编指令地址
            //开始hook
            Inline_Hook.InlineHook(int.Parse(textBox3.Text),5, byteSource.ToArray(), getInt(Method),11+10,"接收消息",(obj) =>{
                StringBuilder sb = new StringBuilder();
                sb.Append("接收消息:");
                int a = 0x68;
                //System.Windows.Forms.MessageBox.Show("esp:"+a.ToString());
                try
                {
                    if (obj.ESP == 0)
                        return;
                    int MsgPtr = NativeAPI.ReadMemoryValue(obj.ESP);
                    if (MsgPtr == 0)
                        return;
                    MsgPtr = NativeAPI.ReadMemoryValue(MsgPtr);
                    if (MsgPtr == 0)
                        return;
                    MsgPtr = NativeAPI.ReadMemoryValue(MsgPtr + 0x68);
                    if (MsgPtr == 0)
                        return;
                    int len = NativeAPI.lstrlenW(MsgPtr);
                    if (len == 0)
                        return;
                    sb.Append(NativeAPI.ReadMemoryStrValue(MsgPtr, len*2+2));
                    sb.Append("\r\n");
                    listBox1.Items.Add(sb.ToString());
                }
                catch (Exception es)
                {
                    File.AppendAllText("error.txt", es.Message);
                }
            });
        }

19 Source : Inline_Hook.cs
with Apache License 2.0
from 1694439208

public static IntPtr InlineHook(int HookAddress, int Hooklen,
            byte[] HookBytes0,int Callback,int CallbackOffset,
            bool IsFront,int CallAddress,string name, Action<Methods.Register> func)
        {
            WeChetHook.DllcallBack dllcallBack = new WeChetHook.DllcallBack((de1, de2, ECX1, EAX1, EDX1, EBX1, ESP1, EBP1, ESI1, EDI1) => {
                func(new Register
                {
                    EAX = EAX1,
                    EBP = EBP1,
                    EBX = EBX1,
                    ECX = ECX1,
                    EDI = EDI1,
                    EDX = EDX1,
                    ESI = ESI1,
                    ESP = ESP1
                });
            });
            int CallHandle = ComputeHash(name);
            Methods.callBacks.Add(CallHandle, dllcallBack);

            List<byte> byteSource1 = new List<byte>();
            byteSource1.AddRange(new byte[] { 199, 134, 240, 2, 0, 0 });
            byteSource1.AddRange(BitConverter.GetBytes(CallHandle));
            byteSource1.AddRange(HookBytes0);

            byte[] hookbytes = byteSource1.ToArray();


            List<byte> byteSource = new List<byte>();
            IntPtr ptr = NativeAPI.VirtualAlloc(0, 128, 4096, 64);
            if (IsFront)
            {
                NativeAPI.WriteProcessMemory(-1, ptr, Add(new byte[] { 232 }, Inline_GetBuf(ptr, CallAddress)), 5, 0);
                NativeAPI.WriteProcessMemory(-1, ptr + 5, hookbytes, hookbytes.Length, 0);
                NativeAPI.WriteProcessMemory(-1, ptr + 5 + CallbackOffset, Inline_GetBuf(ptr + 5 + CallbackOffset - 1, Callback), 4, 0);
                NativeAPI.WriteProcessMemory(-1, ptr + 5 + hookbytes.Length, Add(new byte[] { 233 }, Inline_GetBuf(ptr + 5 + HookBytes0.Length, HookAddress + Hooklen)), 5, 0);
            }
            else {
                NativeAPI.WriteProcessMemory(-1, ptr, hookbytes, hookbytes.Length, 0);
                NativeAPI.WriteProcessMemory(-1, ptr + CallbackOffset, Inline_GetBuf(ptr + CallbackOffset - 1, Callback), 4, 0);
                NativeAPI.WriteProcessMemory(-1, ptr + hookbytes.Length,Add(new byte[] { 232 },Inline_GetBuf(ptr + hookbytes.Length, CallAddress)), Hooklen, 0);
                NativeAPI.WriteProcessMemory(-1, ptr + Hooklen + hookbytes.Length, Add(new byte[] { 233 }, Inline_GetBuf(ptr + Hooklen + HookBytes0.Length, HookAddress + Hooklen)), 5, 0);
            }
            NativeAPI.WriteProcessMemory(-1, new IntPtr(HookAddress), Add(new byte[] { 233 }, Inline_GetBuf(HookAddress, ptr.ToInt32())), 5, 0);
            for (int i = 0; i < Hooklen - 5; i++)
            {
                byteSource.Add(144);
            }
            byte[] ByteFill = byteSource.ToArray();
            NativeAPI.WriteProcessMemory(-1, new IntPtr(HookAddress + 5), ByteFill, ByteFill.Length, 0);
            return ptr;
        }

19 Source : Inline_Hook.cs
with Apache License 2.0
from 1694439208

public static IntPtr InlineHook(int HookAddress, int Hooklen,
            byte[] HookBytes0, int Callback, int CallbackOffset,string name, Action<Methods.Register> func)
        {

            WeChetHook.DllcallBack dllcallBack = new WeChetHook.DllcallBack((de1, de2, ECX1, EAX1, EDX1, EBX1, ESP1, EBP1, ESI1, EDI1) => {
                //int ECX, int EAX, int EDX, int EBX, int ESP, int EBP, int ESI, int EDI
                func(new Register
                {
                    EAX = EAX1,
                    EBP = EBP1,
                    EBX = EBX1,
                    ECX = ECX1,
                    EDI = EDI1,
                    EDX = EDX1,
                    ESI = ESI1,
                    ESP = ESP1
                });
            });
            int CallHandle = ComputeHash(name);
            System.Windows.Forms.MessageBox.Show("CallHandle:" + CallHandle.ToString());
            Methods.callBacks.Add(CallHandle, dllcallBack);

            List<byte> byteSource1 = new List<byte>();
            byteSource1.AddRange(new byte[] { 199, 134, 240, 2, 0, 0 });
            byteSource1.AddRange(BitConverter.GetBytes(CallHandle));//把标识指针绑定到寄存器我觉得不靠谱但是目前没啥问题
            byteSource1.AddRange(HookBytes0);

            byte[] hookbytes = byteSource1.ToArray();


            List<byte> byteSource = new List<byte>();
            IntPtr ptr = NativeAPI.VirtualAlloc(0, 128, 4096, 64);
            NativeAPI.WriteProcessMemory(-1, ptr, hookbytes, hookbytes.Length, 0);
            NativeAPI.WriteProcessMemory(-1, ptr + CallbackOffset, Inline_GetBuf(ptr + CallbackOffset - 1, Callback), 4, 0);
            NativeAPI.WriteProcessMemory(-1, ptr + hookbytes.Length, Add(new byte[] { 233 }, Inline_GetBuf(ptr + hookbytes.Length, HookAddress+ Hooklen)), 5, 0);

            NativeAPI.WriteProcessMemory(-1, new IntPtr(HookAddress), Add(new byte[] { 233 }, Inline_GetBuf(HookAddress, ptr.ToInt32())), 5, 0);
            for (int i = 0; i < Hooklen - 5; i++)
            {
                byteSource.Add(144);
            }
            byte[] ByteFill = byteSource.ToArray();
            NativeAPI.WriteProcessMemory(-1, new IntPtr(HookAddress + 5), ByteFill, ByteFill.Length, 0);
            return ptr;
        }

19 Source : Inline_Hook.cs
with Apache License 2.0
from 1694439208

public static IntPtr InlineHook(int HookAddress, int Hooklen,int Callback)
        {
            List<byte> byteSource = new List<byte>();
            NativeAPI.WriteProcessMemory(-1, new IntPtr(HookAddress), Add(new byte[] { 233 }, Inline_GetBuf(HookAddress, Callback)), 5, 0);
            for (int i = 0; i < Hooklen - 5; i++)
            {
                byteSource.Add(144);
            }
            byte[] ByteFill = byteSource.ToArray();
            NativeAPI.WriteProcessMemory(-1, new IntPtr(HookAddress + 5), ByteFill, ByteFill.Length, 0);
            return IntPtr.Zero;
        }

19 Source : Formatter.Array1.List.cs
with MIT License
from 1996v

public List<Byte> Deserialize(ref BssomReader reader, ref BssomDeserializeContext context)
        {
            if (reader.TryReadNullWithEnsureArray1BuildInType(BssomType.UInt8Code))
            {
                return default;
            }

            context.Option.Security.DepthStep(ref context);
            reader.SkipVariableNumber();
            int len = reader.ReadVariableNumber();
            List<byte> val = new List<Byte>(len);
            for (int i = 0; i < len; i++)
            {
                val.Add(reader.ReadUInt8WithOutTypeHead());
            }
            context.Depth--;
            return val;
        }

19 Source : Form1.cs
with MIT License
from 1y0n

private byte[] Random_Key()
        {
            string t = "";
            for (int i = 0; i < 23; i++)
            {
                RNGCryptoServiceProvider csp = new RNGCryptoServiceProvider();
                byte[] byteCsp = new byte[23];
                csp.GetBytes(byteCsp);
                t = BitConverter.ToString(byteCsp);
            }
            string[] t_array = t.Split('-');
            List<byte> key_list = new List<byte>();

            foreach (string i in t_array)
            {
                key_list.Add(string_to_int(i));
            }

            return key_list.ToArray();
        }

19 Source : Form1.cs
with MIT License
from 1y0n

private string Handle_Payload()
        {
            //对用户输入的payload进行一些转换处理,方便下一步的加密
            string raw_input = textBox1.Text.Trim().Replace("\r\n", "").Replace("\n", "").Replace("\r", ""); //支持多种linux win换行符
            string payload_pattern_csharp = @"\{(.+?)\}";
            string payload_pattern_c = @"=.*"";$";
            string[] raw_payload_array;
            if (Regex.IsMatch(raw_input, payload_pattern_c))
            {
                //c语言格式的shellcode,转成 csharp 格式
                raw_input = raw_input.Replace("\"", "").Replace("\\", ",0").Replace(";", "").Replace("=", "{").Replace("{,", "{ ") + " }";
            }
            string raw_payload = Regex.Matches(raw_input, payload_pattern_csharp)[0].Value.Replace("{", "").Replace("}", "").Trim();
            raw_payload = raw_payload.TrimStart(',');
            raw_payload_array = raw_payload.Split(',');
            List<byte> byte_payload_list = new List<byte>();

            foreach (string i in raw_payload_array)
            {
                byte_payload_list.Add(string_to_int(i));
            }
            byte[] payload_result = byte_payload_list.ToArray();

            //加密payload并转换为字符串,准备写入文件
            byte[] encrypted_payload = Encrypter.Encrypt(KEY, payload_result);
            string string_encrypted_payload = string.Join(",", encrypted_payload);
            //MessageBox.Show(string_encrypted_payload);
            return string_encrypted_payload;
        }

19 Source : X86Assembly.cs
with MIT License
from 20chan

public static byte[] CompileToMachineCode(string asmcode)
        {
            var fullcode = $".intel_syntax noprefix\n_main:\n{asmcode}";
            var path = Path.Combine(Directory.GetCurrentDirectory(), "temp");
            var asmfile = $"{path}.s";
            var objfile = $"{path}.o";
            File.WriteAllText(asmfile, fullcode, new UTF8Encoding(false));
            var psi = new ProcessStartInfo("gcc", $"-m32 -c {asmfile} -o {objfile}")
            {
                RedirectStandardError = true,
                RedirectStandardOutput = true,
                UseShellExecute = false,
                CreateNoWindow = true
            };
            var gcc = Process.Start(psi);
            gcc.WaitForExit();
            if (gcc.ExitCode == 0)
            {
                psi.FileName = "objdump";
                psi.Arguments = $"-z -M intel -d {objfile}";
                var objdump = Process.Start(psi);
                objdump.WaitForExit();
                if (objdump.ExitCode == 0)
                {
                    var output = objdump.StandardOutput.ReadToEnd();
                    var matches = Regex.Matches(output, @"\b[a-fA-F0-9]{2}(?!.*:)\b");
                    var result = new List<byte>();
                    foreach (Match match in matches)
                    {
                        result.Add((byte)Convert.ToInt32(match.Value, 16));
                    }

                    return result.TakeWhile(b => b != 0x90).ToArray();
                }
            }
            else
            {
                var err = gcc.StandardError.ReadToEnd();
            }

            throw new ArgumentException();
        }

19 Source : HttpStreamParser.cs
with MIT License
from 1iveowl

private byte[] ResilientHeader(byte[] b)
        {
            if (!IsDone)
            {
                _last4BytesCircularBuffer.Enqueue(b[0]);
            }
            else
            {
                if (!_parserDelegate.IsHeaderDone)
                {
                    var last4Byte = _last4BytesCircularBuffer.ToArray();

                    if (last4Byte != _correctLast4BytesReversed)
                    {
                        byte[] returnNewLine = { 0x0d, 0x0a };

                        var correctionList = new List<byte>();

                        if (last4Byte[0] != _correctLast4BytesReversed[0] || last4Byte[1] != _correctLast4BytesReversed[1])
                        {
                            correctionList.Add(returnNewLine[0]);
                            correctionList.Add(returnNewLine[1]);
                        }

                        if (last4Byte[2] != _correctLast4BytesReversed[2] || last4Byte[3] != _correctLast4BytesReversed[3])
                        {
                            correctionList.Add(returnNewLine[0]);
                            correctionList.Add(returnNewLine[1]);
                        }

                        if (correctionList.Any())
                        {
                            return correctionList.Concat(correctionList.Select(x => x)).ToArray();
                        }
                    }
                }
            }

            return b;
        }

19 Source : NetworkUtils.cs
with MIT License
from 1ZouLTReX1

public static void SerializeByte(List<byte> byteList, byte data)
    {
        byteList.Add(data);
    }

19 Source : PieceMoves.cs
with MIT License
from 3583Bytes

private static void SetMovesBlackPawn()
        {
            for (byte index = 8; index <= 55; index++)
            {
                var moveset = new PieceMoveSet(new List<byte>());
                
                byte x = (byte)(index % 8);
                byte y = (byte)((index / 8));
                
                //Diagonal Kill
                if (y < 7 && x < 7)
                {
                    moveset.Moves.Add((byte)(index + 8 + 1));
                    MoveArrays.BlackPawnTotalMoves[index]++;
                }
                if (x > 0 && y < 7)
                {
                    moveset.Moves.Add((byte)(index + 8 - 1));
                    MoveArrays.BlackPawnTotalMoves[index]++;
                }
                
                //One Forward
                moveset.Moves.Add((byte)(index + 8));
                MoveArrays.BlackPawnTotalMoves[index]++;

                //Starting Position we can jump 2
                if (y == 1)
                {
                    moveset.Moves.Add((byte)(index + 16));
                    MoveArrays.BlackPawnTotalMoves[index]++;
                }

                MoveArrays.BlackPawnMoves[index] = moveset;
            }
        }

19 Source : PieceMoves.cs
with MIT License
from 3583Bytes

private static void SetMovesRook()
        {
            for (byte y = 0; y < 8; y++)
            {
                for (byte x = 0; x < 8; x++)
                {
                    byte index = (byte)(y + (x * 8));

                    var moveset = new PieceMoveSet(new List<byte>());
                    byte move;

                    byte row = x;
                    byte col = y;

                    while (row < 7)
                    {
                        row++;

                        move = Position(col, row);
                        moveset.Moves.Add(move);
                        MoveArrays.RookTotalMoves1[index]++;
                    }

                    MoveArrays.RookMoves1[index] = moveset;

                    moveset = new PieceMoveSet(new List<byte>());
                    row = x;
                    col = y;

                    while (row > 0)
                    {
                        row--;

                        move = Position(col, row);
                        moveset.Moves.Add(move);
                        MoveArrays.RookTotalMoves2[index]++;
                    }

                    MoveArrays.RookMoves2[index] = moveset;

                    moveset = new PieceMoveSet(new List<byte>());
                    row = x;
                    col = y;

                    while (col > 0)
                    {
                        col--;

                        move = Position(col, row);
                        moveset.Moves.Add(move);
                        MoveArrays.RookTotalMoves3[index]++;
                    }

                    MoveArrays.RookMoves3[index] = moveset;

                    moveset = new PieceMoveSet(new List<byte>());
                    row = x;
                    col = y;

                    while (col < 7)
                    {
                        col++;

                        move = Position(col, row);
                        moveset.Moves.Add(move);
                        MoveArrays.RookTotalMoves4[index]++;
                    }

                    MoveArrays.RookMoves4[index] = moveset;
                }
            }
        }

19 Source : PieceMoves.cs
with MIT License
from 3583Bytes

private static void SetMovesQueen()
        {
            for (byte y = 0; y < 8; y++)
            {
                for (byte x = 0; x < 8; x++)
                {
                    byte index = (byte)(y + (x * 8));

                    var moveset = new PieceMoveSet(new List<byte>());
                    byte move;

                    byte row = x;
                    byte col = y;

                    while (row < 7)
                    {
                        row++;

                        move = Position(col, row);
                        moveset.Moves.Add(move);
                        MoveArrays.QueenTotalMoves1[index]++;
                    }

                    MoveArrays.QueenMoves1[index] = moveset;

                    moveset = new PieceMoveSet(new List<byte>());
                    row = x;
                    col = y;

                    while (row > 0)
                    {
                        row--;

                        move = Position(col, row);
                        moveset.Moves.Add(move);
                        MoveArrays.QueenTotalMoves2[index]++;
                    }

                    MoveArrays.QueenMoves2[index] = moveset;

                    moveset = new PieceMoveSet(new List<byte>());
                    row = x;
                    col = y;

                    while (col > 0)
                    {
                        col--;

                        move = Position(col, row);
                        moveset.Moves.Add(move);
                        MoveArrays.QueenTotalMoves3[index]++;
                    }

                    MoveArrays.QueenMoves3[index] = moveset;

                    moveset = new PieceMoveSet(new List<byte>());
                    row = x;
                    col = y;

                    while (col < 7)
                    {
                        col++;

                        move = Position(col, row);
                        moveset.Moves.Add(move);
                        MoveArrays.QueenTotalMoves4[index]++;
                    }

                    MoveArrays.QueenMoves4[index] = moveset;

                    moveset = new PieceMoveSet(new List<byte>());
                    row = x;
                    col = y;

                    while (row < 7 && col < 7)
                    {
                        row++;
                        col++;

                        move = Position(col, row);
                        moveset.Moves.Add(move);
                        MoveArrays.QueenTotalMoves5[index]++;
                    }

                    MoveArrays.QueenMoves5[index] = moveset;

                    moveset = new PieceMoveSet(new List<byte>());
                    row = x;
                    col = y;

                    while (row < 7 && col > 0)
                    {
                        row++;
                        col--;

                        move = Position(col, row);
                        moveset.Moves.Add(move);
                        MoveArrays.QueenTotalMoves6[index]++;
                    }

                    MoveArrays.QueenMoves6[index] = moveset;

                    moveset = new PieceMoveSet(new List<byte>());
                    row = x;
                    col = y;

                    while (row > 0 && col < 7)
                    {
                        row--;
                        col++;

                        move = Position(col, row);
                        moveset.Moves.Add(move);
                        MoveArrays.QueenTotalMoves7[index]++;
                    }

                    MoveArrays.QueenMoves7[index] = moveset;

                    moveset = new PieceMoveSet(new List<byte>());
                    row = x;
                    col = y;

                    while (row > 0 && col > 0)
                    {
                        row--;
                        col--;

                        move = Position(col, row);
                        moveset.Moves.Add(move);
                        MoveArrays.QueenTotalMoves8[index]++;
                    }

                    MoveArrays.QueenMoves8[index] = moveset;
                }
            }
        }

19 Source : PieceMoves.cs
with MIT License
from 3583Bytes

private static void SetMovesKing()
        {
            for (byte y = 0; y < 8; y++)
            {
                for (byte x = 0; x < 8; x++)
                {
                    byte index = (byte)(y + (x * 8));

                    var moveset = new PieceMoveSet(new List<byte>());
                    byte move;

                    byte row = x;
                    byte col = y;

                    if (row < 7)
                    {
                        row++;

                        move = Position(col, row);
                        moveset.Moves.Add(move);
                        MoveArrays.KingTotalMoves[index]++;
                    }

                    row = x;
                    col = y;

                    if (row > 0)
                    {
                        row--;

                        move = Position(col, row);
                        moveset.Moves.Add(move);
                        MoveArrays.KingTotalMoves[index]++;
                    }

                    row = x;
                    col = y;

                    if (col > 0)
                    {
                        col--;

                        move = Position(col, row);
                        moveset.Moves.Add(move);
                        MoveArrays.KingTotalMoves[index]++;
                    }

                    row = x;
                    col = y;

                    if (col < 7)
                    {
                        col++;

                        move = Position(col, row);
                        moveset.Moves.Add(move);
                        MoveArrays.KingTotalMoves[index]++;
                    }

                    row = x;
                    col = y;

                    if (row < 7 && col < 7)
                    {
                        row++;
                        col++;

                        move = Position(col, row);
                        moveset.Moves.Add(move);
                        MoveArrays.KingTotalMoves[index]++;
                    }

                    row = x;
                    col = y;

                    if (row < 7 && col > 0)
                    {
                        row++;
                        col--;

                        move = Position(col, row);
                        moveset.Moves.Add(move);
                        MoveArrays.KingTotalMoves[index]++;
                    }

                    row = x;
                    col = y;

                    if (row > 0 && col < 7)
                    {
                        row--;
                        col++;

                        move = Position(col, row);
                        moveset.Moves.Add(move);
                        MoveArrays.KingTotalMoves[index]++;
                    }


                    row = x;
                    col = y;

                    if (row > 0 && col > 0)
                    {
                        row--;
                        col--;

                        move = Position(col, row);
                        moveset.Moves.Add(move);
                        MoveArrays.KingTotalMoves[index]++;
                    }

                    MoveArrays.KingMoves[index] = moveset;
                }
            }
        }

19 Source : PieceMoves.cs
with MIT License
from 3583Bytes

private static void SetMovesKnight()
        {
            for (byte y = 0; y < 8; y++)
            {
                for (byte x = 0; x < 8; x++)
                {
                    byte index = (byte)(y + (x * 8));

                    var moveset = new PieceMoveSet(new List<byte>());
                    
                    byte move;

                    if (y < 6 && x > 0)
                    {
                        move = Position((byte)(y + 2), (byte)(x - 1));

                        if (move < 64)
                        {
                            moveset.Moves.Add(move);
                            MoveArrays.KnightTotalMoves[index]++;
                        }
                    }

                    if (y > 1 && x < 7)
                    {
                        move = Position((byte)(y - 2), (byte)(x + 1));

                        if (move < 64)
                        {
                            moveset.Moves.Add(move);
                            MoveArrays.KnightTotalMoves[index]++;
                        }
                    }

                    if (y > 1 && x > 0)
                    {
                        move = Position((byte)(y - 2), (byte)(x - 1));

                        if (move < 64)
                        {
                            moveset.Moves.Add(move);
                            MoveArrays.KnightTotalMoves[index]++;
                        }
                    }

                    if (y < 6 && x < 7)
                    {
                        move = Position((byte)(y + 2), (byte)(x + 1));

                        if (move < 64)
                        {
                            moveset.Moves.Add(move);
                            MoveArrays.KnightTotalMoves[index]++;
                        }
                    }

                    if (y > 0 && x < 6)
                    {
                        move = Position((byte)(y - 1), (byte)(x + 2));

                        if (move < 64)
                        {
                            moveset.Moves.Add(move);
                            MoveArrays.KnightTotalMoves[index]++;
                        }
                    }

                    if (y < 7 && x > 1)
                    {
                        move = Position((byte)(y + 1), (byte)(x - 2));

                        if (move < 64)
                        {
                            moveset.Moves.Add(move);
                            MoveArrays.KnightTotalMoves[index]++;
                        }
                    }

                    if (y > 0 && x > 1)
                    {
                        move = Position((byte)(y - 1), (byte)(x - 2));

                        if (move < 64)
                        {
                            moveset.Moves.Add(move);
                            MoveArrays.KnightTotalMoves[index]++;
                        }
                    }
                    
                    if (y < 7 && x < 6)
                    {
                        move = Position((byte)(y + 1), (byte)(x + 2));

                        if (move < 64)
                        {
                            moveset.Moves.Add(move);
                            MoveArrays.KnightTotalMoves[index]++;
                        }
                    }

                    MoveArrays.KnightMoves[index] = moveset;
                }
            }
        }

19 Source : PieceMoves.cs
with MIT License
from 3583Bytes

private static void SetMovesBishop()
        {
            for (byte y = 0; y < 8; y++)
            {
                for (byte x = 0; x < 8; x++)
                {
                    byte index = (byte)(y + (x * 8));

                    var moveset = new PieceMoveSet(new List<byte>());
                    byte move;

                    byte row = x;
                    byte col = y;

                    while (row < 7 && col < 7)
                    {
                        row++;
                        col++;

                        move = Position(col, row);
                        moveset.Moves.Add(move);
                        MoveArrays.BishopTotalMoves1[index]++;
                    }

                    MoveArrays.BishopMoves1[index] = moveset;
                    moveset = new PieceMoveSet(new List<byte>());

                    row = x;
                    col = y;

                    while (row < 7 && col > 0)
                    {
                        row++;
                        col--;

                        move = Position(col, row);
                        moveset.Moves.Add(move);
                        MoveArrays.BishopTotalMoves2[index]++;
                    }

                    MoveArrays.BishopMoves2[index] = moveset;
                    moveset = new PieceMoveSet(new List<byte>());

                    row = x;
                    col = y;

                    while (row > 0 && col < 7)
                    {
                        row--;
                        col++;

                        move = Position(col, row);
                        moveset.Moves.Add(move);
                        MoveArrays.BishopTotalMoves3[index]++;
                    }

                    MoveArrays.BishopMoves3[index] = moveset;
                    moveset = new PieceMoveSet(new List<byte>());

                    row = x;
                    col = y;

                    while (row > 0 && col > 0)
                    {
                        row--;
                        col--;

                        move = Position(col, row);
                        moveset.Moves.Add(move);
                        MoveArrays.BishopTotalMoves4[index]++;
                    }

                    MoveArrays.BishopMoves4[index] = moveset;
                }
            }
        }

19 Source : PieceMoves.cs
with MIT License
from 3583Bytes

private static void SetMovesWhitePawn()
        {
            for (byte index = 8; index <= 55; index++)
            {
                byte x = (byte)(index % 8);
                byte y = (byte)((index / 8));

                var moveset = new PieceMoveSet(new List<byte>());
               
                //Diagonal Kill
                if (x < 7 && y > 0)
                {
                    moveset.Moves.Add((byte)(index - 8 + 1));
                    MoveArrays.WhitePawnTotalMoves[index]++;
                }
                if (x > 0 && y > 0)
                {
                    moveset.Moves.Add((byte)(index - 8 - 1));
                    MoveArrays.WhitePawnTotalMoves[index]++;
                }

                //One Forward
                moveset.Moves.Add((byte)(index - 8));
                MoveArrays.WhitePawnTotalMoves[index]++;

                //Starting Position we can jump 2
                if (y == 6)
                {
                    moveset.Moves.Add((byte)(index - 16));
                    MoveArrays.WhitePawnTotalMoves[index]++;
                }

                MoveArrays.WhitePawnMoves[index] = moveset;
            }
        }

19 Source : HMACT64.cs
with BSD 3-Clause "New" or "Revised" License
from 3gstudent

public void update(byte[] input, int offset, int len)
        {
            for (int i = offset; i < (offset + len); i++)
            {
                this.buffer.Add(input[i]);
            }
        }

19 Source : ASCIIEncoding.cs
with BSD 3-Clause "New" or "Revised" License
from 3gstudent

public static byte[] GetBytes(string sString, bool bQuiet)
        {
            List<byte> list = new List<byte>();
            foreach (char ch in sString)
            {
                if ((ch >= 'a') && (ch <= 'z'))
                {
                    int num = ((byte) ch) - 0x61;
                    list.Add((byte) (0x61 + num));
                    continue;
                }

                if ((ch >= 'A') && (ch <= 'Z'))
                {
                    int num2 = ((byte) ch) - 0x41;
                    list.Add((byte) (0x41 + num2));
                    continue;
                }

                if ((ch >= '0') && (ch <= '9'))
                {
                    int num3 = ((byte) ch) - 0x30;
                    list.Add((byte) (0x30 + num3));
                    continue;
                }

                switch (ch)
                {
                    case '\0':
                    {
                        list.Add(0);
                        continue;
                    }
                    case '\n':
                    {
                        list.Add(10);
                        continue;
                    }
                    case '\r':
                    {
                        list.Add(13);
                        continue;
                    }
                    case ' ':
                    {
                        list.Add(0x20);
                        continue;
                    }
                    case '!':
                    {
                        list.Add(0x21);
                        continue;
                    }
                    case '"':
                    {
                        list.Add(0x22);
                        continue;
                    }
                    case '#':
                    {
                        list.Add(0x23);
                        continue;
                    }
                    case '$':
                    {
                        list.Add(0x24);
                        continue;
                    }
                    case '%':
                    {
                        list.Add(0x25);
                        continue;
                    }
                    case '&':
                    {
                        list.Add(0x26);
                        continue;
                    }
                    case '\'':
                    {
                        list.Add(0x27);
                        continue;
                    }
                    case '(':
                    {
                        list.Add(40);
                        continue;
                    }
                    case ')':
                    {
                        list.Add(0x29);
                        continue;
                    }
                    case '*':
                    {
                        list.Add(0x2a);
                        continue;
                    }
                    case '+':
                    {
                        list.Add(0x2b);
                        continue;
                    }
                    case ',':
                    {
                        list.Add(0x2c);
                        continue;
                    }
                    case '-':
                    {
                        list.Add(0x2d);
                        continue;
                    }
                    case '.':
                    {
                        list.Add(0x2e);
                        continue;
                    }
                    case '/':
                    {
                        list.Add(0x2f);
                        continue;
                    }
                    case ':':
                    {
                        list.Add(0x3a);
                        continue;
                    }
                    case ';':
                    {
                        list.Add(0x3b);
                        continue;
                    }
                    case '<':
                    {
                        list.Add(60);
                        continue;
                    }
                    case '=':
                    {
                        list.Add(0x3d);
                        continue;
                    }
                    case '>':
                    {
                        list.Add(0x3e);
                        continue;
                    }
                    case '?':
                    {
                        list.Add(0x3f);
                        continue;
                    }
                    case '@':
                    {
                        list.Add(0x40);
                        continue;
                    }
                    case '[':
                    {
                        list.Add(0x5b);
                        continue;
                    }
                    case '\\':
                    {
                        list.Add(0x5c);
                        continue;
                    }
                    case ']':
                    {
                        list.Add(0x5d);
                        continue;
                    }
                    case '^':
                    {
                        list.Add(0x5e);
                        continue;
                    }
                    case '_':
                    {
                        list.Add(0x5f);
                        continue;
                    }
                    case '`':
                    {
                        list.Add(0x60);
                        continue;
                    }
                    case '{':
                    {
                        list.Add(0x7b);
                        continue;
                    }
                    case '|':
                    {
                        list.Add(0x7c);
                        continue;
                    }
                    case '}':
                    {
                        list.Add(0x7d);
                        continue;
                    }
                    case '~':
                    {
                        list.Add(0x7e);
                        continue;
                    }
                    case '\x00a1':
                    {
                        list.Add(0xa1);
                        continue;
                    }
                    case '\x00a2':
                    {
                        list.Add(0xa2);
                        continue;
                    }
                    case '\x00a3':
                    {
                        list.Add(0xa3);
                        continue;
                    }
                    case '\x00a4':
                    {
                        list.Add(0xa4);
                        continue;
                    }
                    case '\x00a5':
                    {
                        list.Add(0xa5);
                        continue;
                    }
                    case '\x00a6':
                    {
                        list.Add(0xa6);
                        continue;
                    }
                    case '\x00a7':
                    {
                        list.Add(0xa7);
                        continue;
                    }
                    case '\x00a8':
                    {
                        list.Add(0xa8);
                        continue;
                    }
                    case '\x00a9':
                    {
                        list.Add(0xa9);
                        continue;
                    }
                    case '\x00aa':
                    {
                        list.Add(170);
                        continue;
                    }
                    case '\x00ab':
                    {
                        list.Add(0xab);
                        continue;
                    }
                    case '\x00ac':
                    {
                        list.Add(0xac);
                        continue;
                    }
                    case '\x00ae':
                    {
                        list.Add(0xae);
                        continue;
                    }
                    case '\x00af':
                    {
                        list.Add(0xaf);
                        continue;
                    }
                    case '\x00b0':
                    {
                        list.Add(0xb0);
                        continue;
                    }
                    case '\x00b1':
                    {
                        list.Add(0xb1);
                        continue;
                    }
                    case '\x00b2':
                    {
                        list.Add(0xb2);
                        continue;
                    }
                    case '\x00b3':
                    {
                        list.Add(0xb3);
                        continue;
                    }
                    case '\x00b4':
                    {
                        list.Add(180);
                        continue;
                    }
                    case '\x00b5':
                    {
                        list.Add(0xb5);
                        continue;
                    }
                    case '\x00b6':
                    {
                        list.Add(0xb6);
                        continue;
                    }
                    case '\x00b7':
                    {
                        list.Add(0xb7);
                        continue;
                    }
                    case '\x00b8':
                    {
                        list.Add(0xb8);
                        continue;
                    }
                    case '\x00b9':
                    {
                        list.Add(0xb9);
                        continue;
                    }
                    case '\x00ba':
                    {
                        list.Add(0xba);
                        continue;
                    }
                    case '\x00bb':
                    {
                        list.Add(0xbb);
                        continue;
                    }
                    case '\x00bc':
                    {
                        list.Add(0xbc);
                        continue;
                    }
                    case '\x00bd':
                    {
                        list.Add(0xbd);
                        continue;
                    }
                    case '\x00be':
                    {
                        list.Add(190);
                        continue;
                    }
                    case '\x00bf':
                    {
                        list.Add(0xbf);
                        continue;
                    }
                    case '\x00c0':
                    {
                        list.Add(0xc0);
                        continue;
                    }
                    case '\x00c1':
                    {
                        list.Add(0xc1);
                        continue;
                    }
                    case '\x00c2':
                    {
                        list.Add(0xc2);
                        continue;
                    }
                    case '\x00c3':
                    {
                        list.Add(0xc3);
                        continue;
                    }
                    case '\x00c4':
                    {
                        list.Add(0xc4);
                        continue;
                    }
                    case '\x00c5':
                    {
                        list.Add(0xc5);
                        continue;
                    }
                    case '\x00c6':
                    {
                        list.Add(0xc6);
                        continue;
                    }
                    case '\x00c7':
                    {
                        list.Add(0xc7);
                        continue;
                    }
                    case '\x00c8':
                    {
                        list.Add(200);
                        continue;
                    }
                    case '\x00c9':
                    {
                        list.Add(0xc9);
                        continue;
                    }
                    case '\x00ca':
                    {
                        list.Add(0xca);
                        continue;
                    }
                    case '\x00cb':
                    {
                        list.Add(0xcb);
                        continue;
                    }
                    case '\x00cc':
                    {
                        list.Add(0xcc);
                        continue;
                    }
                    case '\x00cd':
                    {
                        list.Add(0xcd);
                        continue;
                    }
                    case '\x00ce':
                    {
                        list.Add(0xce);
                        continue;
                    }
                    case '\x00cf':
                    {
                        list.Add(0xcf);
                        continue;
                    }
                    case '\x00d0':
                    {
                        list.Add(0xd0);
                        continue;
                    }
                    case '\x00d1':
                    {
                        list.Add(0xd1);
                        continue;
                    }
                    case '\x00d2':
                    {
                        list.Add(210);
                        continue;
                    }
                    case '\x00d3':
                    {
                        list.Add(0xd3);
                        continue;
                    }
                    case '\x00d4':
                    {
                        list.Add(0xd4);
                        continue;
                    }
                    case '\x00d5':
                    {
                        list.Add(0xd5);
                        continue;
                    }
                    case '\x00d6':
                    {
                        list.Add(0xd6);
                        continue;
                    }
                    case '\x00d7':
                    {
                        list.Add(0xd7);
                        continue;
                    }
                    case '\x00d8':
                    {
                        list.Add(0xd8);
                        continue;
                    }
                    case '\x00d9':
                    {
                        list.Add(0xd9);
                        continue;
                    }
                    case '\x00da':
                    {
                        list.Add(0xda);
                        continue;
                    }
                    case '\x00db':
                    {
                        list.Add(0xdb);
                        continue;
                    }
                    case '\x00dc':
                    {
                        list.Add(220);
                        continue;
                    }
                    case '\x00dd':
                    {
                        list.Add(0xdd);
                        continue;
                    }
                    case '\x00de':
                    {
                        list.Add(0xde);
                        continue;
                    }
                    case '\x00df':
                    {
                        list.Add(0xdf);
                        continue;
                    }
                    case '\x00e0':
                    {
                        list.Add(0xe0);
                        continue;
                    }
                    case '\x00e1':
                    {
                        list.Add(0xe1);
                        continue;
                    }
                    case '\x00e2':
                    {
                        list.Add(0xe2);
                        continue;
                    }
                    case '\x00e3':
                    {
                        list.Add(0xe3);
                        continue;
                    }
                    case '\x00e4':
                    {
                        list.Add(0xe4);
                        continue;
                    }
                    case '\x00e5':
                    {
                        list.Add(0xe5);
                        continue;
                    }
                    case '\x00e6':
                    {
                        list.Add(230);
                        continue;
                    }
                    case '\x00e7':
                    {
                        list.Add(0xe7);
                        continue;
                    }
                    case '\x00e8':
                    {
                        list.Add(0xe8);
                        continue;
                    }
                    case '\x00e9':
                    {
                        list.Add(0xe9);
                        continue;
                    }
                    case '\x00ea':
                    {
                        list.Add(0xea);
                        continue;
                    }
                    case '\x00eb':
                    {
                        list.Add(0xeb);
                        continue;
                    }
                    case '\x00ec':
                    {
                        list.Add(0xec);
                        continue;
                    }
                    case '\x00ed':
                    {
                        list.Add(0xed);
                        continue;
                    }
                    case '\x00ee':
                    {
                        list.Add(0xee);
                        continue;
                    }
                    case '\x00ef':
                    {
                        list.Add(0xef);
                        continue;
                    }
                    case '\x00f0':
                    {
                        list.Add(240);
                        continue;
                    }
                    case '\x00f1':
                    {
                        list.Add(0xf1);
                        continue;
                    }
                    case '\x00f2':
                    {
                        list.Add(0xf2);
                        continue;
                    }
                    case '\x00f3':
                    {
                        list.Add(0xf3);
                        continue;
                    }
                    case '\x00f4':
                    {
                        list.Add(0xf4);
                        continue;
                    }
                    case '\x00f5':
                    {
                        list.Add(0xf5);
                        continue;
                    }
                    case '\x00f6':
                    {
                        list.Add(0xf6);
                        continue;
                    }
                    case '\x00f7':
                    {
                        list.Add(0xf7);
                        continue;
                    }
                    case '\x00f8':
                    {
                        list.Add(0xf8);
                        continue;
                    }
                    case '\x00f9':
                    {
                        list.Add(0xf9);
                        continue;
                    }
                    case '\x00fa':
                    {
                        list.Add(250);
                        continue;
                    }
                    case '\x00fb':
                    {
                        list.Add(0xfb);
                        continue;
                    }
                    case '\x00fc':
                    {
                        list.Add(0xfc);
                        continue;
                    }
                    case '\x00fd':
                    {
                        list.Add(0xfd);
                        continue;
                    }
                    case '\x00fe':
                    {
                        list.Add(0xfe);
                        continue;
                    }
                    case '\x00ff':
                    {
                        list.Add(0xff);
                        continue;
                    }
                    case 'Œ':
                    {
                        list.Add(140);
                        continue;
                    }
                    case 'œ':
                    {
                        list.Add(0x9c);
                        continue;
                    }
                    case 'Š':
                    {
                        list.Add(0x8a);
                        continue;
                    }
                    case 'š':
                    {
                        list.Add(0x9a);
                        continue;
                    }
                    case 'Ž':
                    {
                        list.Add(0x8e);
                        continue;
                    }
                    case 'ž':
                    {
                        list.Add(0x9e);
                        continue;
                    }
                    case 'ƒ':
                    {
                        list.Add(0x83);
                        continue;
                    }
                    case 'Ÿ':
                    {
                        list.Add(0x9f);
                        continue;
                    }
                    case '–':
                    {
                        list.Add(150);
                        continue;
                    }
                    case '—':
                    {
                        list.Add(0x97);
                        continue;
                    }
                    case '‘':
                    {
                        list.Add(0x91);
                        continue;
                    }
                    case '’':
                    {
                        list.Add(0x92);
                        continue;
                    }
                    case '‚':
                    {
                        list.Add(130);
                        continue;
                    }
                    case '“':
                    {
                        list.Add(0x93);
                        continue;
                    }
                    case '”':
                    {
                        list.Add(0x94);
                        continue;
                    }
                    case '„':
                    {
                        list.Add(0x84);
                        continue;
                    }
                    case '†':
                    {
                        list.Add(0x86);
                        continue;
                    }
                    case '‡':
                    {
                        list.Add(0x87);
                        continue;
                    }
                    case '•':
                    {
                        list.Add(0x95);
                        continue;
                    }
                    case '…':
                    {
                        list.Add(0x85);
                        continue;
                    }
                    case '˜':
                    {
                        list.Add(0x98);
                        continue;
                    }
                    case 'ˆ':
                    {
                        list.Add(0x88);
                        continue;
                    }
                    case '€':
                    {
                        list.Add(0x80);
                        continue;
                    }
                    case '™':
                    {
                        list.Add(0x99);
                        continue;
                    }
                    case '‹':
                    {
                        list.Add(0x8b);
                        continue;
                    }
                    case '›':
                    {
                        list.Add(0x9b);
                        continue;
                    }
                    case '‰':
                    {
                        list.Add(0x89);
                        continue;
                    }
                }

                if (!bQuiet)
                {
                    throw new Exception("Invalid ASCII char: " + ch);
                }
            }

            return list.ToArray();
        }

19 Source : NTLM.cs
with BSD 3-Clause "New" or "Revised" License
from 3gstudent

private static byte[] getNTLMv2Response(byte[] responseKeyNT, byte[] serverChallenge, byte[] clientChallenge, byte[] nanos1601, byte[] av_pairs, out byte[] keyExchangeKey)
        {
            List<byte> list = new List<byte> { 1, 1, 0, 0, 0, 0, 0, 0 };
            list.AddRange(nanos1601);
            list.AddRange(clientChallenge);
            list.Add(0);
            list.Add(0);
            list.Add(0);
            list.Add(0);
            list.AddRange(av_pairs);

            return computeResponse(responseKeyNT, serverChallenge, list.ToArray(), 0, list.Count, out keyExchangeKey);
        }

19 Source : EndianBinaryReader.cs
with MIT License
from 91Act

public string ReadStringToNull()
        {
            var bytes = new List<byte>();
            byte b;
            while (BaseStream.Position != BaseStream.Length && (b = ReadByte()) != 0)
                bytes.Add(b);
            return Encoding.UTF8.GetString(bytes.ToArray());
        }

19 Source : MicroVM.Assembler.cs
with MIT License
from a-downing

void AddData(Variable var, int size) {
            //todo: don't ignore size
            programData.Add(var.val32.byte0);
            programData.Add(var.val32.byte1);
            programData.Add(var.val32.byte2);
            programData.Add(var.val32.byte3);
        }

19 Source : CellLandblock.cs
with GNU Affero General Public License v3.0
from ACEmulator

public override void Unpack(BinaryReader reader)
        {
            Id = reader.ReadUInt32();

            uint hasObjects = reader.ReadUInt32();
            if (hasObjects == 1)
                HasObjects = true;

            // Read in the terrain. 9x9 so 81 records.
            for (int i = 0; i < 81; i++)
            {
                var terrain = reader.ReadUInt16();
                Terrain.Add(terrain);
            }

            // Read in the height. 9x9 so 81 records
            for (int i = 0; i < 81; i++)
            {
                var height = reader.ReadByte();
                Height.Add(height);
            }

            reader.AlignBoundary();
        }

19 Source : Polygon.cs
with GNU Affero General Public License v3.0
from ACEmulator

public void Unpack(BinaryReader reader)
        {
            NumPts      = reader.ReadByte();
            Stippling   = (StipplingType)reader.ReadByte();

            SidesType   = (CullMode)reader.ReadInt32();
            PosSurface  = reader.ReadInt16();
            NegSurface  = reader.ReadInt16();

            for (short i = 0; i < NumPts; i++)
                VertexIds.Add(reader.ReadInt16());

            if (!Stippling.HasFlag(StipplingType.NoPos))
            {
                for (short i = 0; i < NumPts; i++)
                    PosUVIndices.Add(reader.ReadByte());
            }

            if (SidesType == CullMode.Clockwise && !Stippling.HasFlag(StipplingType.NoNeg))
            {
                for (short i = 0; i < NumPts; i++)
                    NegUVIndices.Add(reader.ReadByte());
            }

            if (SidesType == CullMode.None)
            {
                NegSurface = PosSurface;
                NegUVIndices = PosUVIndices;
            }
        }

19 Source : BytesWriter.cs
with MIT License
from adrenak

public void WriteBytes(byte[] block) {
            foreach (var b in block)
                m_Bytes.Add(b);
        }

19 Source : BytesWriter.cs
with MIT License
from adrenak

public void WriteByte(byte b) {
            m_Bytes.Add(b);
        }

19 Source : Program.cs
with GNU General Public License v3.0
from AdvancedHacker101

public byte[] ToArray(string des)
        {
            List<byte> data = new List<byte>();
            bool ctn = false;
            for (int i = 0; i < des.Length; i++)
            {
                if (ctn)
                {
                    ctn = !ctn;
                    continue;
                }
                data.Add((byte)int.Parse(des[i].ToString() + des[i+1].ToString(), System.Globalization.NumberStyles.HexNumber));
                if (!ctn) ctn = !ctn;
            }
            return data.ToArray();
        }

19 Source : ModEntry.cs
with GNU General Public License v3.0
from aedenthorn

private Texture2D CreateCustomCharacter(RNPC npc, string type)
        {
            Texture2D sprite = this.Helper.Content.Load<Texture2D>("replacedets/body/" + npc.bodyType + "_" + type + ".png", ContentSource.ModFolder);
            Texture2D hairT = this.Helper.Content.Load<Texture2D>("replacedets/hair/" + npc.hairStyle + "_" + type + ".png", ContentSource.ModFolder);
            Texture2D eyeT = this.Helper.Content.Load<Texture2D>("replacedets/body/" + npc.gender + "_eyes_" + type + ".png", ContentSource.ModFolder);

            Texture2D eyeBackT = null;
            Texture2D noseT = null;
            Texture2D mouthT = null;
            if (type == "portrait")
            {
                eyeBackT = this.Helper.Content.Load<Texture2D>("replacedets/body/" + npc.gender + "_eyes_back.png", ContentSource.ModFolder);
                noseT = this.Helper.Content.Load<Texture2D>("replacedets/body/" + npc.gender + "_nose.png", ContentSource.ModFolder);
                mouthT = this.Helper.Content.Load<Texture2D>("replacedets/body/" + npc.gender + "_mouth.png", ContentSource.ModFolder);
            }
            Texture2D topT = this.Helper.Content.Load<Texture2D>("replacedets/transparent_" + type + ".png", ContentSource.ModFolder);
            Texture2D bottomT = topT;
            Texture2D shoesT = topT;

            // clothes

            // try and share with other type (char/portrait)
            string[] clothes;
            if (npc.clothes != null)
            {
                clothes = npc.clothes;
            }
            else
            {
                string npcString = string.Join("/", npc.npcString.Split('/').Take(7)) + "/" + npc.bodyType;
                List<string> potentialClothes = GetHighestRankedStrings(npcString, RNPCclothes.data, 8);

                clothes = potentialClothes[Game1.random.Next(0, potentialClothes.Count)].Split('^');
                //base.Monitor.Log(string.Join(" | ", clothes), LogLevel.Debug);
                npc.clothes = clothes;
                npc.topRandomColour = new string[] { Game1.random.Next(0, 255).ToString(), Game1.random.Next(0, 255).ToString(), Game1.random.Next(0, 255).ToString() };
            }

            if (clothes[0] != "")
            {
                topT = this.Helper.Content.Load<Texture2D>("replacedets/clothes/" + clothes[0] + "_" + type + ".png", ContentSource.ModFolder);
            }
            if (clothes[1] != "" && type == "character")
            {
                bottomT = this.Helper.Content.Load<Texture2D>("replacedets/clothes/" + clothes[1] + ".png", ContentSource.ModFolder);
            }
            if (clothes[2] != "" && type == "character")
            {
                shoesT = this.Helper.Content.Load<Texture2D>("replacedets/clothes/" + clothes[2] + ".png", ContentSource.ModFolder);
            }

            Color[] data = new Color[sprite.Width * sprite.Height];
            Color[] dataH = new Color[hairT.Width * hairT.Height];
            Color[] dataE = new Color[eyeT.Width * eyeT.Height];
            Color[] dataEB = null;
            Color[] dataN = null;
            Color[] dataM = null;
            if (type == "portrait")
            {
                dataEB = new Color[eyeBackT.Width * eyeBackT.Height];
                dataN = new Color[noseT.Width * noseT.Height];
                dataM = new Color[mouthT.Width * mouthT.Height];
            }
            Color[] dataT = new Color[topT.Width * topT.Height];
            Color[] dataB = new Color[bottomT.Width * bottomT.Height];
            Color[] dataS = new Color[shoesT.Width * shoesT.Height];
            sprite.GetData(data);
            hairT.GetData(dataH);
            eyeT.GetData(dataE);
            if (type == "portrait")
            {
                eyeBackT.GetData(dataEB);
                noseT.GetData(dataN);
                mouthT.GetData(dataM);
            }
            topT.GetData(dataT);
            bottomT.GetData(dataB);
            shoesT.GetData(dataS);

            string[] skinRBG = npc.skinColour.Split(' ');
            string[] eyeRBG = npc.eyeColour.Split(' ');
            List<string> hairRBGs = npc.hairColour.Split('^').ToList();

            string[] baseColourT = clothes[3] == "any" ? npc.topRandomColour : null;

            string[] baseColourB;
            switch (clothes[4])
            {
                case "any":
                    baseColourB = new string[] { Game1.random.Next(0, 255).ToString(), Game1.random.Next(0, 255).ToString(), Game1.random.Next(0, 255).ToString() };
                    break;
                case "top":
                    baseColourB = baseColourT;
                    break;
                default:
                    baseColourB = null;
                    break;
            }
            string[] baseColourS;
            switch (clothes[5])
            {
                case "any":
                    baseColourS = new string[] { Game1.random.Next(0, 255).ToString(), Game1.random.Next(0, 255).ToString(), Game1.random.Next(0, 255).ToString() };
                    break;
                case "top":
                    baseColourS = baseColourT;
                    break;
                case "bottom":
                    baseColourS = baseColourB;
                    break;
                default:
                    baseColourS = null;
                    break;
            }

            // make hair gradient

            List<string> hairGreyStrings = new List<string>();
            for (int i = 0; i < dataH.Length; i++)
            {
                if (dataH[i].R == dataH[i].G && dataH[i].R == dataH[i].B && dataH[i].G == dataH[i].B) // greyscale
                {
                    if (!hairGreyStrings.Contains(dataH[i].R.ToString()))
                    { // only add one of each grey
                        hairGreyStrings.Add(dataH[i].R.ToString());
                    }
                }
            }

            // make same number of greys as colours in gradient

            if (hairRBGs.Count > hairGreyStrings.Count) // ex 9 and 6
            {
                hairGreyStrings = LengthenToMatch(hairGreyStrings, hairRBGs);
            }
            else if (hairRBGs.Count < hairGreyStrings.Count)
            {
                hairRBGs = LengthenToMatch(hairRBGs, hairGreyStrings);

            }
            List<byte> hairGreys = new List<byte>();
            foreach (string str in hairGreyStrings)
            {
                hairGreys.Add(byte.Parse(str));
            }
            hairGreys.Sort();
            hairGreys.Reverse(); // lightest to darkest
            //Alert(hairGreys.Count+ " " +hairRBGs.Count);
            
            // start putting it together

            for (int i = 0; i < data.Length; i++)
            {
                if (dataH.Length > i && dataH[i] != Color.Transparent)
                {
                    if (dataH[i].R == dataH[i].G && dataH[i].R == dataH[i].B && dataH[i].G == dataH[i].B) // greyscale
                    {
                        // hair gradient

                        // for cases where fewer greys than colours (multiple of same grey)
                        List<int> greyMatches = new List<int>();
                        for (int j = 0; j < hairGreys.Count; j++)
                        {
                            if (hairGreys[j] == dataH[i].R)
                            {
                                greyMatches.Add(j);
                            }
                        }

                        string[] hairRBG;
                        int rnd = Game1.random.Next(0, greyMatches.Count);
                        int match = greyMatches[rnd];
                        hairRBG = hairRBGs[match].Split(' '); // turns single grey into set of colours

                        data[i] = new Color(byte.Parse(hairRBG[0]), byte.Parse(hairRBG[1]), byte.Parse(hairRBG[2]), dataH[i].A);
                    }
                    else // ignore already coloured parts
                    {
                        data[i] = dataH[i];
                    }
                }
                else if (dataT.Length > i && dataT[i] != Color.Transparent)
                {
                    data[i] = baseColourT != null ? ColorizeGrey(baseColourT, dataT[i]) : dataT[i];
                }
                else if (dataB.Length > i && dataB[i] != Color.Transparent)
                {
                    data[i] = baseColourB != null ? ColorizeGrey(baseColourB, dataB[i]) : dataB[i];
                }
                else if (dataS.Length > i && dataS[i] != Color.Transparent)
                {
                    data[i] = baseColourS != null ? ColorizeGrey(baseColourS, dataS[i]) : dataS[i];
                }
                else if (dataE.Length > i && dataE[i] != Color.Transparent)
                {
                    if (dataE[i] != Color.White)
                    {
                        data[i] = ColorizeGrey(eyeRBG, dataE[i]);
                    }
                    else
                    {
                        data[i] = Color.White;
                    }
                }
                else if (type == "portrait" && dataEB.Length > i && dataEB[i] != Color.Transparent)
                {
                    data[i] = ColorizeGrey(skinRBG, dataEB[i]);
                }
                else if (type == "portrait" && dataN.Length > i && dataN[i] != Color.Transparent)
                {
                    data[i] = ColorizeGrey(skinRBG, dataN[i]);
                }
                else if (type == "portrait" && dataM.Length > i && dataM[i] != Color.Transparent)
                {
                    if (dataM[i] != Color.White)
                    {
                        data[i] = ColorizeGrey(skinRBG, dataM[i]);
                    }
                    else
                    {
                        data[i] = Color.White;
                    }
                }
                else if (data[i] != Color.Transparent)
                {
                    data[i] = ColorizeGrey(skinRBG, data[i]);
                }
            }
            sprite.SetData<Color>(data);
            return sprite;
        }

19 Source : IRCompiler.cs
with GNU General Public License v3.0
from Aekras1a

byte[] ReadDataContent(Node node) {
			var content = node[1];
			if (content.Id == (int)IRConstants.DATA_STRING) {
				var str = ((Token)content[0]).Image;
				return Encoding.UTF8.GetBytes(str.Substring(1, str.Length - 2));
			}
			if (content.Id == (int)IRConstants.DATA_BUFFER) {
				var bytes = new List<byte>();
				for (int i = 0; i < content.Count; i++) {
					if (content[i].Id == (int)IRConstants.NUM)
						bytes.Add(ParseByte((Token)content[i]));
				}
				return bytes.ToArray();
			}
			Debug.replacedert(false);
			return null;
		}

19 Source : ReplayAnimationRecorder.cs
with GNU General Public License v3.0
from aelariane

public byte[] SerializeAnimationsHeader()
        {
            List<byte> bytes = new List<byte>();

            var bytesLength = new byte[2];
            int index = 0;

            ExitGames.Client.Photon.Protocol.Serialize((short)animationsDictionary.Count, bytesLength, ref index);

            foreach (var pair in animationsDictionary)
            {
                var stringBytes = Encoding.UTF8.GetBytes(pair.Key);
                bytes.Add((byte)stringBytes.Length);
                bytes.AddRange(stringBytes);
            }

            return bytes.ToArray();
        }

19 Source : EventsCounter.cs
with GNU General Public License v3.0
from aelariane

public void Count(byte eventCode)
        {
            lock (events)
            {
                events[eventCode]++;
                if (!receivedEvents.Contains(eventCode))
                {
                    receivedEvents.Add(eventCode);
                }
            }
        }

19 Source : ReplayAnimationRecorder.cs
with GNU General Public License v3.0
from aelariane

public byte[] SerializeAnimationCalls()
        {
            List<byte> bytes = new List<byte>();

            bytes.Add((byte)animationsDictionary.Count);
            foreach(var pair in animationsDictionary)
            {
                var stringBytes = Encoding.UTF8.GetBytes(pair.Key);
                bytes.Add((byte)stringBytes.Length);
                bytes.AddRange(stringBytes);
            }

            var animsCountLength = new byte[4];
            int index = 0;
            ExitGames.Client.Photon.Protocol.Serialize(playedAnimations.Count, animsCountLength, ref index);
            bytes.AddRange(animsCountLength);

            foreach (var info in playedAnimations)
            {
                var animBytes = info.Serialize();
                bytes.AddRange(animBytes);
            }

            return bytes.ToArray();
        }

19 Source : PBitStream.cs
with GNU General Public License v3.0
from aelariane

public void Add(bool val)
    {
        int num = this.totalBits / 8;
        if (num > this.streamBytes.Count - 1 || this.totalBits == 0)
        {
            this.streamBytes.Add(0);
        }
        if (val)
        {
            int num2 = 7 - this.totalBits % 8;
            List<byte> list2;
            List<byte> list = list2 = this.streamBytes;
            int index2;
            int index = index2 = num;
            byte b = list2[index2];
            list[index] = (byte)(b | (byte)(1 << num2));
        }
        this.totalBits++;
    }

19 Source : BinaryMerkleTestTest.cs
with MIT License
from AElfProject

[Theory]
        [InlineData("SkMGjviAAs9bnYvv6cKcafbhf6tbRGQGK93WgKvZoCoS5amMK", "75900000000000000000",
            "96de8fc8c256fa1e1556d41af431cace7dca68707c78dd88c3acab8b17164c47",
            "0x0eb4305ab57ea86f1f2940cc32c86f5870c5463e0e9c57c6ead6a38cbb2ded90")]
        [InlineData("2ADXLcyKMGGrRe9aGC7XMXECv8cxz3Tos1z6PJHSfyXguSaVb5", "5500000000000000000",
            "d9147961436944f43cd99d28b2bbddbf452ef872b30c8279e255e7daafc7f946",
            "0xd4998a64d00f9b9178337fcebcb193494ceefc7b2ee68031a5060ef407d7ae2d")]
        public void CalculateHashTest(string address, string amount, string uid, string result)
        {
            var hashFromString = HashHelper.ComputeFrom(address);

            var parsedResult = decimal.Parse(amount);
            var originTokenSizeInByte = 32;
            var preHolderSize = originTokenSizeInByte - 16;
            var bytesFromDecimal = decimal.GetBits(parsedResult).Reverse().ToArray();

            if (preHolderSize < 0)
                bytesFromDecimal = bytesFromDecimal.TakeLast(originTokenSizeInByte).ToArray();

            var amountBytes = new List<byte>();
            bytesFromDecimal.Aggregate(amountBytes, (cur, i) =>
            {
                while (cur.Count < preHolderSize)
                {
                    cur.Add(new byte());
                }
                
                cur.AddRange(i.ToBytes());
                return cur;
            });
            var hashFromAmount = HashHelper.ComputeFrom(amountBytes.ToArray());
            var hashFromUid = Hash.LoadFromByteArray(ByteArrayHelper.HexStringToByteArray(uid));
            var hash = HashHelper.ConcatAndCompute(hashFromAmount, hashFromString, hashFromUid);
            replacedert.True(hash == Hash.LoadFromByteArray(ByteArrayHelper.HexStringToByteArray(result)));
        }

19 Source : DataReader.cs
with GNU General Public License v3.0
from aenemenate

public static Plant GetPlant(string name)
        {
            XElement plantData = null;

            // load all the plants
            XElement root = XElement.Load("res/data/PlantTypes.xml");
            IEnumerable<XElement> plants =
                from el in root.Elements("plant")
                select el;

            // choose the right creature
            foreach (XElement p in plants)
                if (ReadAttribute(p.FirstAttribute).Equals(name))
                    plantData = p;

            if (plantData == null)
                return null;

            bool edible = System.Convert.ToBoolean(ReadAttribute(plantData.Element("edible").Attribute("bool")));
            int growthInterval = System.Convert.ToInt32(ReadAttribute(plantData.Attribute("growth_interval")));
            int seedRadius = System.Convert.ToInt32(ReadAttribute(plantData.Attribute("seed_radius")));

            byte r = System.Convert.ToByte(ReadAttribute(plantData.Element("fore_color").Attribute("r"))),
                 g = System.Convert.ToByte(ReadAttribute(plantData.Element("fore_color").Attribute("g"))),
                 b = System.Convert.ToByte(ReadAttribute(plantData.Element("fore_color").Attribute("b")));
            Color? foreColor = new Color(r, g, b);

            IEnumerable<XElement> growthStagesTemp =
                from el in plantData.Element("growth_stages").Elements("growth_stage")
                select el;
            List<byte> growthStages = new List<byte>();
            foreach (XElement growthStage in growthStagesTemp)
                growthStages.Add(System.Convert.ToByte(ReadAttribute(growthStage.Attribute("graphic"))));

            string requirement;
            if (ReadAttribute(plantData.Element("requirement").FirstAttribute).Equals(""))
                requirement = "";
            else {
                requirement =
                    ReadAttribute(plantData.Element("requirement").FirstAttribute)
                    + ';'
                    + ReadAttribute(plantData.Element("requirement").Attribute("type"))
                    + ';'
                    + ReadAttribute(plantData.Element("requirement").Attribute("dist"));
            }

            return new Plant(growthStages[0], name, growthInterval, seedRadius, growthStages, requirement, edible, foreColor);
        }

19 Source : CultistMod.cs
with Apache License 2.0
from Aeolic

public static void AddCultistToLists(PlayerControl playerControl)
        {
            if (!IsCultist(playerControl.PlayerId))
            {
                CultistList.Add(playerControl.PlayerId);
                CultistNameList.Add(playerControl.Data.PlayerName);
            }
        }

19 Source : Decompress.cs
with GNU General Public License v3.0
from Aeroblast

public byte[] Decode(byte[] data)
        {
            List<byte> r = new List<byte>();
            int pos = 0;
            while (pos < data.Length)
            {
                byte c = data[pos];
                pos++;
                if (c >= 1 && c <= 8)
                {
                    r.AddRange(Util.SubArray(data, pos, c));
                    pos += c;
                }
                else if (c < 128)
                {
                    r.Add(c);
                }
                else if (c >= 192)
                {
                    r.Add(0x20);
                    r.Add((byte)( c ^ 128));
                }
                else
                {
                    if (pos < data.Length)
                    {
                        int cx = (c << 8) | data[pos];
                        pos++;
                        int m = (cx >> 3) & 0x07ff;
                        int n = (cx & 7) + 3;
                        if (m > n) { r.AddRange(Util.SubArray(r.ToArray(), r.Count - m, n)); }
                        else
                        {
                            for (int i = 0; i < n; i++)
                            {
                                if (m == 1) r.AddRange(Util.SubArray(r.ToArray(), r.Count - m, m));
                                else r.Add(r[r.Count - m]);
                            }
                        }
                    }
                }
            }

            return r.ToArray();
        }

19 Source : CultistMod.cs
with Apache License 2.0
from Aeolic

public static void AddCultistToLists(byte playerId)
        {
            if (!IsCultist(playerId))
            {
                CultistList.Add(playerId);
                foreach (var player in PlayerControl.AllPlayerControls)
                {
                    if (player.PlayerId == playerId)
                    {
                        CultistNameList.Add(player.Data.PlayerName);
                    }
                }
            }
        }

19 Source : ByteArray.cs
with GNU General Public License v2.0
from afrantzis

static public byte[] FromString(string s, int baseNum)
	{
		int i = 0;
		int len = s.Length;
		ByteList ba = new ByteList();

		// ignore leading whitespace
		while (i < len && s[i] == ' ') i++;

		while (i < len) {
			int k = 1;
			while (i + k < len &&  s[i+k] != ' ' && k < BaseConverter.DefaultMinDigits[baseNum]) k++;

			ba.Add((byte)BaseConverter.ConvertToNum(s, i, i + k - 1, baseNum));

			// skip spaces
			i = i + k;
			while (i < len && s[i] == ' ') i++;
		}

		return ba.ToArray();
	}

19 Source : Asn1IntegerConverter.cs
with Mozilla Public License 2.0
from agebullhu

private static byte[] TwoToThePowerOf(int n)
        {
            using (ThreadLockScope.Scope(powersOfTwo))
            {
                if (n >= powersOfTwo.Count)
                {
                    for (var i = powersOfTwo.Count; i <= n; i++)
                    {
                        var list = new List<byte>(powersOfTwo[i - 1]);
                        byte num2 = 0;
                        for (var j = 0; j < list.Count; j++)
                        {
                            var num4 = (byte)((list[j] << 1) + num2);
                            list[j] = (byte)(num4 % 10);
                            num2 = (byte)(num4 / 10);
                        }
                        if (num2 > 0)
                        {
                            list.Add(num2);
                        }
                        powersOfTwo.Add(list.ToArray());
                    }
                }
                return powersOfTwo[n];
            }
        }

19 Source : Memory.cs
with MIT License
from aghontpi

private byte[] ConvertPattern(String pattern)
        {
            List<byte> convertertedArray = new List<byte>();
            foreach (String each in pattern.Split(' '))
            {
                if (each == "??") { convertertedArray.Add(Convert.ToByte("0", 16)); }
                else{ convertertedArray.Add(Convert.ToByte(each,16)); }
            }
            return convertertedArray.ToArray();

        }

19 Source : RSAHelper.cs
with GNU General Public License v3.0
from aiportal

private static string ComponentKey(byte[] b1, byte[] b2)
        {
            List<byte> list = new List<byte>();
            //在前端加上第一个数组的长度值 这样今后可以根据这个值分别取出来两个数组
            list.Add((byte)b1.Length);
            list.AddRange(b1);
            list.AddRange(b2);
            byte[] b = list.ToArray();
            return Convert.ToBase64String(b);
        }

19 Source : Option.cs
with Apache License 2.0
from ajuna-network

public override byte[] Encode()
        {
           var bytes = new List<byte>();
           if (OptionFlag)
            {
                bytes.Add(1);
                bytes.AddRange(Value.Encode());

            } else
            {
                bytes.Add(0);
            }

            return bytes.ToArray();
        }

19 Source : AccountId.cs
with Apache License 2.0
from ajuna-network

public override byte[] Encode()
        {
            var bytes = new List<byte>();
            switch (Constants.AddressVersion)
            {
                case 0:
                    return Bytes;
                case 1:
                    bytes.Add(0xFF);
                    bytes.AddRange(Bytes);
                    return bytes.ToArray();
                case 2:
                    bytes.Add(0x00);
                    bytes.AddRange(Bytes);
                    return bytes.ToArray();
                default:
                    throw new NotImplementedException("Unknown address version please refer to Constants.cs");
            }
        }

19 Source : Method.cs
with Apache License 2.0
from ajuna-network

public byte[] Encode()
        {
            var result = new List<byte>();
            result.Add(ModuleIndex);
            result.Add(CallIndex);
            result.AddRange(Parameters);
            return result.ToArray();
        }

19 Source : UnCheckedExtrinsic.cs
with Apache License 2.0
from ajuna-network

public byte[] Encode()
        {
            if (Signed && Signature == null)
            {
                throw new Exception("Missing payload signature for signed transaction.");
            }

            var list = new List<byte>();

            // 4 is the TRANSACTION_VERSION constant and it is 7 bits long, the highest bit 1 for signed transaction, 0 for unsigned.
            list.Add((byte)(Constants.ExtrinsicVersion | (Signed ? 0x80 : 0)));

            // 32 bytes + prefix depending on address encoding in chain, see Constants.Address_version
            list.AddRange(Account.Encode());

            // key type ed = 00 and sr = FF
            list.Add(Account.KeyTypeByte);

            // add signature if exists
            if (Signature != null)
            {
                list.AddRange(Signature);
            }
            else
            {

            }

            list.AddRange(Era.Encode());

            list.AddRange(Nonce.Encode());

            list.AddRange(Tip.Encode());

            list.AddRange(Method.Encode());

            return Utils.SizePrefixedByteArray(list);
        }

19 Source : UnCheckedExtrinsic.cs
with Apache License 2.0
from ajuna-network

public byte[] Encode()
        {
            if (Signed && Signature == null)
            {
                throw new Exception("Missing payload signature for signed transaction.");
            }

            var list = new List<byte>();

            // 4 is the TRANSACTION_VERSION constant and it is 7 bits long, the highest bit 1 for signed transaction, 0 for unsigned.
            list.Add((byte)(Constants.ExtrinsicVersion | (Signed ? 0x80 : 0)));

            // 32 bytes + prefix depending on address encoding in chain, see Constants.Address_version
            list.AddRange(Account.Encode());

            // key type ed = 00 and sr = FF
            list.Add(Account.KeyTypeByte);

            // add signature if exists
            if (Signature != null)
            {
                list.AddRange(Signature);
            }
            else
            {

            }

            list.AddRange(Era.Encode());

            list.AddRange(Nonce.Encode());

            list.AddRange(Tip.Encode());

            list.AddRange(Method.Encode());

            return Utils.SizePrefixedByteArray(list);
        }

19 Source : CompactInteger.cs
with Apache License 2.0
from ajuna-network

public byte[] Encode()
        {
            if (this <= 63) return new byte[] {this << 2};

            if (this <= 0x3FFF)
                return new byte[]
                {
                    ((this & 0x3F) << 2) | 0x01,
                    (this & 0xFFC0) >> 6
                };

            if (this <= 0x3FFFFFFF)
            {
                var result = new byte[4];
                result[0] = ((this & 0x3F) << 2) | 0x02;
                this >>= 6;
                for (var i = 1; i < 4; ++i)
                {
                    result[i] = this & 0xFF;
                    this >>= 8;
                }

                return result;
            }
            else
            {
                var b0 = new List<byte>();
                while (this > 0)
                {
                    b0.Add(this & 0xFF);
                    this >>= 8;
                }

                var result = new List<byte>
                {
                    (byte) (((b0.Count - 4) << 2) | 0x03)
                };
                result.AddRange(b0);
                return result.ToArray();
            }
        }

19 Source : MethodTest.cs
with Apache License 2.0
from ajuna-network

[Test]
        public void MethodEncodeTest()
        {
            replacedert.True("0x0602".Equals(Utils.Bytes2HexString(new Method(0x06, 0x02).Encode()),
                StringComparison.InvariantCultureIgnoreCase));

            replacedert.True("0x06000100000000000000".Equals(
                Utils.Bytes2HexString(new Method(0x06, 0x00, Utils.HexToByteArray("0x0100000000000000")).Encode()),
                StringComparison.InvariantCultureIgnoreCase));

            var parameters = new List<byte>();
            parameters.Add(0xFF);
            parameters.AddRange(Utils.GetPublicKeyFrom("5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY"));
            replacedert.AreEqual("0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d".ToUpper(),
                Utils.Bytes2HexString(Utils.GetPublicKeyFrom("5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY"))
                    .ToUpper());
            parameters.AddRange(new CompactInteger(100).Encode());
            var balanceTransfer = new Method(0x04, 0x00, parameters.ToArray());
            replacedert.True("0x0400ffd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d9101".Equals(
                Utils.Bytes2HexString(balanceTransfer.Encode()), StringComparison.InvariantCultureIgnoreCase));
        }

19 Source : PayloadTest.cs
with Apache License 2.0
from ajuna-network

[Test]
        public void EncodeExtraTest()
        {
            var genesisHash = new byte[]
                {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
            var blockHash = new byte[]
                {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};

            var era = new Era(2048, 99, false);

            var paramsList = new List<byte>();
            paramsList.Add(0xFF);
            paramsList.AddRange(
                Utils.HexToByteArray(
                    "d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d")); // Utils.GetPublicKeyFrom("5FfBQ3kwXrbdyoqLPvcXRp7ikWydXawpNs2Ceu3WwFdhZ8W4");          
            CompactInteger amount = 100;
            paramsList.AddRange(amount.Encode());
            var parameters = paramsList.ToArray();

            var method = new Method(0x06, 0x00, parameters);
            var methodBytes = Utils.StringValueArrayBytesArray(
                "6, 0, 255, 212, 53, 147, 199, 21, 253, 211, 28, 97, 20, 26, 189, 4, 169, 159, 214, 130, 44, 133, 88, 133, 76, 205, 227, 154, 86, 132, 231, 165, 109, 162, 125, 145, 1");

            replacedert.AreEqual(methodBytes, method.Encode());

            var genesis = new Hash();
            genesis.Create(genesisHash);

            var startEra = new Hash();
            startEra.Create(blockHash);

            var signedExtensions = new SignedExtensions(259, 1, genesis, startEra, era, 0, 0);

            var payload = new Payload(method, signedExtensions);

            var payloadBytes = Utils.StringValueArrayBytesArray(
                "6, 0, 255, 212, 53, 147, 199, 21, 253, 211, 28, 97, 20, 26, 189, 4, 169, 159, 214, 130, 44, 133, 88, 133, 76, 205, 227, 154, 86, 132, 231, 165, 109, 162, 125, 145, 1, 58, 6, 0, 0, 3, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0");

            replacedert.AreEqual(payloadBytes, payload.Encode());
        }

See More Examples