VarInt class, TxIn/TXOut/Tx serializarion, some CKey and CPubKey methods
[NovacoinLibrary.git] / Novacoin / Interop.cs
1 \feffusing System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using System.Threading.Tasks;
6
7 namespace Novacoin
8 {
9     class Interop
10     {
11         public static byte[] LEBytes(ushort n)
12         {
13             byte[] resultBytes = BitConverter.GetBytes(n);
14
15             if (!BitConverter.IsLittleEndian)
16             {
17                 Array.Reverse(resultBytes);
18             }
19
20             return resultBytes;
21         }
22
23         public static byte[] LEBytes(uint n)
24         {
25             byte[] resultBytes = BitConverter.GetBytes(n);
26
27             if (!BitConverter.IsLittleEndian)
28             {
29                 Array.Reverse(resultBytes);
30             }
31
32             return resultBytes;
33         }
34
35         public static byte[] LEBytes(ulong n)
36         {
37             byte[] resultBytes = BitConverter.GetBytes(n);
38
39             if (!BitConverter.IsLittleEndian)
40             {
41                 Array.Reverse(resultBytes);
42             }
43
44             return resultBytes;
45         }
46
47         public static byte[] BEBytes(ushort n)
48         {
49             byte[] resultBytes = BitConverter.GetBytes(n);
50
51             if (BitConverter.IsLittleEndian)
52             {
53                 Array.Reverse(resultBytes);
54             }
55
56             return resultBytes;
57         }
58
59         public static byte[] BEBytes(uint n)
60         {
61             byte[] resultBytes = BitConverter.GetBytes(n);
62
63             if (BitConverter.IsLittleEndian)
64             {
65                 Array.Reverse(resultBytes);
66             }
67
68             return resultBytes;
69         }
70
71         public static byte[] BEBytes(ulong n)
72         {
73             byte[] resultBytes = BitConverter.GetBytes(n);
74
75             if (BitConverter.IsLittleEndian)
76             {
77                 Array.Reverse(resultBytes);
78             }
79
80             return resultBytes;
81         }
82
83     }
84 }