}; //Array containing the cipher values. //Converts binary stream to alphanumeric cipher. public string compress(DAABitArray binaryStream) { string compressedStream = ""; for (int i = 5; i < binaryStream.NumBits; i = i + 6) //Iterate through every six bits. { compressedStream = compressedStream + alphanumerics[binaryStream.GetBitRange(i - 5, i)]; //Add alphanumeric to output stream. } return(compressedStream); }
public string Interpertation(DAABitArray inDAABitArray) { string output = ""; /*how many bits are from the DAABitArray*/ int numBit = inDAABitArray.NumBits; /*for every 6 bits from the DAABitArray need to be converted*/ long bitRange; for (int i = 0; i < numBit - 5; i += 6) { bitRange = inDAABitArray.GetBitRange(i, i + 5); output += Selection(bitRange); } /*add the bits if the number of bit is not multiple of 6*/ int shiftNum, startPoint; long addBit = 0; if (numBit % 6 != 0) { /*check how many bits we need fill in*/ startPoint = numBit - numBit % 6; /*check where it need start fill in*/ shiftNum = 6 - numBit % 6; /*call the function form the DAABitarray to fill in*/ addBit = inDAABitArray.GetBitRange(startPoint, numBit - 1); output += Selection(addBit << shiftNum); } return(output); }