Steganografie/Encryption/BaseEncryption.cs
/// <summary>
/// Converts a list of bits to
/// an array of bytes
/// </summary>
/// <param name="bits"></param>
/// <returns></returns>
Converts a list of bits to
an array of bytes
Converts a list of bits to an array of bytes
protected byte[] BitsToBytes(List<int> bits)
		{
			for (int i = bits.Count % 8; i > -1; i--)
			{
				bits.Remove(bits.Count - i - 1);
			}
			var bytes = new byte[bits.Count / 8];
			for (var i = 0; i < bits.Count /8 ; i++)
			{
				var values = new bool[8];
				for (var j = 0; j < 8; j++)
				{
					values[j] = Convert.ToBoolean(bits[j + 8 * i]);
				}
				new BitArray(values).CopyTo(bytes, i);
			}
			return bytes;
		}
protected byte [ ] BitsToBytes ( List < int > bits ) { for ( int i = bits . Count % 8 ; i > - 1 ; i -- ) { bits . Remove ( bits . Count - i - 1 ) ; } var bytes = new byte [ bits . Count / 8 ] ; for ( var i = 0 ; i < bits . Count / 8 ; i ++ ) { var values = new bool [ 8 ] ; for ( var j = 0 ; j < 8 ; j ++ ) { values [ j ] = Convert . ToBoolean ( bits [ j + 8 * i ] ) ; } new BitArray ( values ) . CopyTo ( bytes , i ) ; } return bytes ; }
Converts a list of bits to
an array of bytes
Converts a list of bits to an array of bytes
None
bits
List<int>
None