Пример #1
0
 /// <summary>
 /// Takes a BitString and adds LSbs to make the BitString hit a byte boundry.
 /// Returns the original BitString if already at a byte boundry.
 /// </summary>
 /// <param name="bs">The BitString to pad.</param>
 /// <returns></returns>
 public static BitString PadToNextByteBoundry(BitString bs, bool padOntoLsb = true)
 {
     return(PadToModulus(bs, BITSINBYTE, padOntoLsb));
 }
Пример #2
0
 public BitString ConcatenateBits(BitString bitsToAppend)
 {
     return(BitString.ConcatenateBits(this, bitsToAppend));
 }
Пример #3
0
 /// <summary>
 /// Gets a substring of bits from the MSB direction.
 /// </summary>
 /// <param name="bsToSub"></param>
 /// <param name="startIndex">Start index from the MSB side. Most significant bit is index 0.</param>
 /// <param name="numberOfBits"></param>
 /// <returns></returns>
 public static BitString MSBSubstring(BitString bsToSub, int startIndex, int numberOfBits)
 {
     return(Substring(bsToSub, bsToSub.BitLength - startIndex - numberOfBits, numberOfBits));
 }
Пример #4
0
 public static BitString GetLeastSignificantBits(int numBits, BitString bitString)
 {
     return(BitString.Substring(bitString, 0, numBits));
 }
Пример #5
0
 public BitString GetLeastSignificantBits(int numBits)
 {
     return(BitString.GetLeastSignificantBits(numBits, this));
 }
Пример #6
0
 public BitString OR(BitString comparisonBitString)
 {
     return(OR(this, comparisonBitString));
 }
Пример #7
0
 public static BitString GetMostSignificantBits(int numBits, BitString bitString)
 {
     return(BitString.Substring(bitString, bitString.BitLength - numBits, numBits));
 }
Пример #8
0
 public BitString BitStringSubtraction(BitString right)
 {
     return(BitStringSubtraction(this, right));
 }
Пример #9
0
 /// <summary>
 /// Adds two bit strings together - e.g. "11" (3) + 111 (7) = 1010 (10).
 /// Similar to <see cref="AddWithModulo(NIST.CVP.ACVTS.Libraries.Math.BitString,NIST.CVP.ACVTS.Libraries.Math.BitString,int)"/>, but without truncation.
 /// </summary>
 /// <param name="left"></param>
 /// <param name="right"></param>
 /// <returns></returns>
 public BitString BitStringAddition(BitString right)
 {
     return(BitStringAddition(this, right));
 }
Пример #10
0
 public BitString LSBRotate(int distance)
 {
     return(BitString.LSBRotate(this, distance));
 }
Пример #11
0
 public BitString LSBShift()
 {
     return(BitString.LSBShift(this));
 }
Пример #12
0
        /// <summary>
        /// Rotates bist in the LSB direction. Rotate puts the bits that 'fall off' onto the end.
        /// </summary>
        /// <param name="bStr"></param>
        /// <param name="distance">Amount the bits to rotate.</param>
        /// <returns></returns>
        public static BitString LSBRotate(BitString bStr, int distance)
        {
            var minDistance = distance % bStr.BitLength;

            return(BitString.MSBRotate(bStr, bStr.BitLength - minDistance));
        }
Пример #13
0
        public static BitString NOT(BitString source)
        {
            BitString val = source.GetDeepCopy();

            return(new BitString(val.Bits.Not()));
        }
Пример #14
0
 public BitString AND(BitString comparisonBitString)
 {
     return(AND(this, comparisonBitString));
 }
Пример #15
0
 public static BitString PadToModulusMsb(BitString bs, int modulus)
 {
     return(PadToModulus(bs, modulus, false));
 }
Пример #16
0
 public BitString AddWithModulo(BitString right, int moduloPower)
 {
     return(AddWithModulo(this, right, moduloPower));
 }
Пример #17
0
 public static BitString ReverseByteOrder(BitString input)
 {
     return(new BitString(MsbLsbConversionHelpers.ReverseByteOrder(input.ToBytes())));
 }
Пример #18
0
        private static BitString PadShorterBitStringWithZeroes(BitString longerBitString, BitString shorterBitString)
        {
            BitArray newArray = new BitArray(longerBitString.BitLength);

            for (int i = 0; i < shorterBitString.BitLength; i++)
            {
                newArray[i] = shorterBitString.Bits[i];
            }

            return(new BitString(newArray));
        }