コード例 #1
0
ファイル: Form1.cs プロジェクト: abrar2008/Chat_Application
        public string Decrypt(string p_strMsg)
        {
            string str  = p_strMsg;
            string Text = "";

            while (str.Length % 3 != 0)
            {
                str += " ";
            }

            //   int index = 0;
            for (int i = 0; i < str.Length; i++)
            {
                if (((i) % 3) == 0)
                {
                    //HillCipher m_objCipher = ciphers[index++];
                    HillCipher m_objCipher = new HillCipher();
                    char[]     ch          = new char[3];

                    ch = str.ToCharArray(i, 3);
                    string ThreeCharString = new string(ch);

                    //Text += m_objCipher.decryption(ThreeCharString);
                    //                    MessageBox.Show("Original = " + ThreeCharString + "\n" + "Cipher = " + m_objCipher.encryption() + "\n" + "Decrypted = " + m_objCipher.decryption());
                    Text += m_objCipher.de(ThreeCharString);
                }
            }
            return(Text);
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: abrar2008/Chat_Application
        public string Encrypt(string p_strMsg)
        {
            string str    = p_strMsg;
            string cipher = "";

            while (str.Length % 3 != 0)
            {
                str += "{";
            }

            //  ciphers.Clear();
            for (int i = 0; i < str.Length; i++)
            {
                if (((i) % 3) == 0)
                {
                    HillCipher m_objCipher = new HillCipher();
                    char[]     ch          = new char[3];
                    ch = str.ToCharArray(i, 3);
                    string ThreeCharString = new string(ch);
                    m_objCipher.SetString(ThreeCharString);
//                    cipher += m_objCipher.encryption();
                    //        ciphers.Add(m_objCipher);
                    cipher += m_objCipher.encryption();
                    //m_objCipher.de(en);
                    // MessageBox.Show("Original = " + ThreeCharString + "\n" + "Cipher = " +en + "\n" + "Decrypted = ");
                }
            }
            return(cipher);
        }