Beispiel #1
0
        public static string FileReadToBinary(string filename)
        {
            FileStream fs = new FileStream("C:\\" + filename, FileMode.Open);

            Console.WriteLine("File size : " + fs.Length);

            int fileLength = (int)fs.Length;

            StringBuilder text = new StringBuilder((int)fs.Length * 8);

            byte[] bytes      = new byte[100];
            int    startindex = 0;
            int    IsEnd      = -1;

            while (fs.Read(bytes, startindex, bytes.Length) != 0)
            {
                if (IsEnd > 0)
                {
                }
                foreach (byte b in bytes)
                {
                    if (text.Length == fileLength * 8)
                    {
                        break;
                    }

                    text.Append(ProcessDES.FromDeciamlToBinary(b));
                }
            }

            fs.Close();
            return(text.ToString());
        }
Beispiel #2
0
        public string DoPermutation(string text, int[,] order)
        {
            string PermutatedText = "";

            int rowIndex = Convert.ToInt32(text[0].ToString() + text[text.Length - 1].ToString(), 2);
            int colIndex = Convert.ToInt32(text.Substring(1, 4), 2);

            PermutatedText = ProcessDES.FromDeciamlToBinary(order[rowIndex, colIndex]);

            return(PermutatedText);
        }