- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
public class OctetString
{
private byte[] m_bDataArray = null;
public OctetString(byte[] data_i)
{
//copy input data
m_bDataArray = new byte[data_i.Length];
data_i.CopyTo(m_bDataArray, 0);
}
//...
//checks if a bit on a specfied position is set
public bool CheckIfBitOnPositionIsSet(int iPosition)
{
if (m_bDataArray.Length * 8 < iPosition)
{
return false;
}
int iByte = iPosition / 8;
int iBit = iPosition % 8;
byte bData = m_bDataArray[iByte];
if((bData & (0x1 << iBit)) != 0)
{
return true;
}
else
{
return false;
}
}
}
byte[] data = { 0xFF, 0x3F };
OctetString octetString = new OctetString(data);
Assert.AreEqual(false, octetString.CheckIfBitOnPositionIsSet(8));