private static int[] GetBitsFromHexStr(string hexStr) { int[] bits = new int[64]; string inputBinary = HexConverter.HexToBinary(hexStr); bits = inputBinary.Select(i => int.Parse(i + "")).ToArray(); return bits; }
private static List <int[]> SplitToBitBlocks(string strHex) { var blocks = new List <int[]>(); var strBinary = HexConverter.HexToBinary(strHex); var binaryBlocks = strBinary.SplitInParts(64).ToArray(); foreach (var block in binaryBlocks) { var bits = block.Select(el => int.Parse(el + "")).ToArray(); blocks.Add(bits); } return(blocks); }
public static List <int[]> SplitToBitBlocksUsingTBC(string strHex) { var blocks = new List <int[]>(); var strBinary = HexConverter.HexToBinary(strHex); var binaryBlocks = strBinary.SplitInParts(64).ToArray(); int paddingValue = strBinary.Last() == '0' ? 1 : 0; for (int i = 0; i < binaryBlocks.Length; i++) { var currentBlock = binaryBlocks[i]; if (currentBlock.Length < 64) { currentBlock = TBC(currentBlock); } var bits = currentBlock.Select(el => int.Parse(el + "")).ToArray(); blocks.Add(bits); } // Add last block blocks.Add(Enumerable.Repeat(paddingValue, 64).ToArray()); return(blocks); }