예제 #1
0
        public string plain(string cplain)
        {
            string ppbb = "";

            for (int i = 0; i < cplain.Length; i += 4)
            {
                string H = "";
                for (int j = i; j < i + 4; j++)
                {
                    H += cplain[j];
                }
                decdes s = new decdes();
                int    L = s.abdo(H);
                char   Q = L < 10 ? '0' : 'A';
                if (L > 9)
                {
                    L -= 10;
                }
                while (L > 0)
                {
                    L = L - 1;
                    Q++;
                }
                ppbb += Q;
            }
            cplain = ppbb;

            return(cplain);
        }
예제 #2
0
        public string keyenc(string key)
        {
            string kckckc = "";

            if (key[1] == 'x')
            {
                for (int i = 2; i < 18; i++)
                {
                    int index;
                    if (Char.IsLetter(key[i]))
                    {
                        index = (key[i] - 'A') + 10;
                    }
                    else if (!Char.IsLetter(key[i]))
                    {
                        index = key[i] - '0';
                    }
                    else
                    {
                        index = key[i] - '0';
                    }
                    decdes s = new decdes();
                    kckckc += s.hd(index);
                }
            }
            else if (key[1] != 'x')
            {
                kckckc = key;
            }


            return(kckckc);
        }
예제 #3
0
        public string leftright(string ch, char [] chararr)
        {
            string le = "", ri = "";
            string ppll = new string(chararr);

            for (int i = 0; i < 32; i++)
            {
                ri += ppll[i];
            }
            for (int i = 32; i < 64; i++)
            {
                le += ppll[i];
            }
            for (int i = 16; i >= 1; i--)
            {
                me();
                string Right2 = le;
                decdes s      = new decdes();
                string res    = s.rf(le, listofkeys[i - 1]);
                string Left2  = "";
                for (int uu = 0; uu < ri.Length; uu++)
                {
                    if (ri[uu] == res[uu])
                    {
                        Left2 += '0';
                    }
                    else
                    {
                        Left2 += '1';
                    }
                }
                le = Left2;
                ri = Right2;
            }

            if (ch == "r")
            {
                return(ri);
            }
            else if (ch == "l")
            {
                return(le);
            }

            return(" ");
        }
예제 #4
0
        public string plainnnn(string Plain)
        {
            string pb = "";

            for (int i = 0; i < 64; i++)
            {
                pb += Plain[i1[i] - 1];
            }
            Plain = pb;

            string l = "", r = "";

            for (int i = 32; i < 64; i++)
            {
                r = r + Plain[i];
            }
            for (int i = 0; i < 32; i++)
            {
                l = l + Plain[i];
            }

            for (int i = 1; i <= 16; i++)
            {
                string l2  = r;
                decdes s   = new decdes();
                string res = s.rf(r, listofkeys[i - 1]);
                string r2  = "";
                for (int uu = 0; uu < l.Length; uu++)
                {
                    if (l[uu] == res[uu])
                    {
                        r2 += '0';
                    }
                    else
                    {
                        r2 += '1';
                    }
                }
                l = l2;
                r = r2;
            }
            pb = "";
            for (int i = 0; i < 32; i++)
            {
                pb = pb + r[i];
            }
            for (int i = 0; i < 32; i++)
            {
                pb = pb + l[i];
            }
            Plain = pb;

            pb = "";
            for (int i = 0; i < 64; i++)
            {
                pb += Plain[i2[i] - 1];
            }
            Plain = pb;
            pb    = "";
            for (int i = 0; i < Plain.Length; i += 4)
            {
                string ff = "";
                for (int j = i; j < i + 4; j++)
                {
                    ff += Plain[j];
                }
                decdes s  = new decdes();
                int    ii = s.abdo(ff);
                char   A  = ii < 10 ? '0' : 'A';
                if (ii > 9)
                {
                    ii -= 10;
                }
                while (ii > 0)
                {
                    ii--;
                    A++;
                }
                pb += A;
            }
            Plain = pb;

            return(Plain);
        }