using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace GetCardData { public partial class BitConverter { public static string ToString(byte[] raw, int offset, int length) { string ret = String.Empty; for (int i = 0; i < length; i++) ret += (char)raw[offset + i]; return ret; } public static short ToBEShort16(byte[] raw, int offset) { short value = (short)(((raw[offset + 0] << 8) & 0xFF00) | raw[offset + 1]); return value; } public static short ToLEShort16(byte[] raw, int offset) { short value = (short)((short)raw[offset + 0] | (short)(raw[offset + 1] * 0x100)); return value; } public static ushort ToLEUShort16(byte[] raw, int offset) { ushort value = (ushort)((ushort)raw[offset + 0] | (ushort)(raw[offset + 1] * 0x100)); return value; } public static uint ToLEUInt32(byte[] raw, int offset) { uint value = (uint)((uint)raw[offset + 0] | (uint)((raw[offset + 1] << 8) & 0xFF00)) | (uint)((raw[offset + 2] << 16 & 0xFF00)) | (uint)((raw[offset + 3] << 24 & 0xFF0000)); return value; } } }