Click here to Skip to main content
16,009,318 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i need modifiead AES with changes mixcoloumn proses with initial permutation table on DES, i dont how to make code with C# winform, could you help me to make the program?

What I have tried:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Security.Cryptography;
using System.IO;
using System.Data;



namespace test
{
    class cryptografi
    {
        private string Plaint_Text;
        private string Key;
        private string cipherText;
        private string[] cipherText2;
        private string cipherTextTampil;
        
        
        public string [] CipherText2
        {
            get
            {
                return CipherText2;
            }
            set
            {
                cipherText2 = value;
            }
        }
        public string CipherText
        {
            get
            {
                return cipherText;
            }
            set
            {
                cipherText = value;
            }
        }
        public string CipherTextTampil
        {
            get
            {
                return cipherTextTampil;
            }
            set
            {
                cipherTextTampil = value;
            }
        }
        public string PlainText
        {
            get
            {
                return Plaint_Text;
            }
            set
            {
                Plaint_Text = value;
            }
        }
        private string[,] SBOX_SubByte =
        {
                { "63", "7C", "77", "7B", "F2", "6B", "6F", "C5", "30", "01", "67", "2B", "FE", "D7", "AB", "76" },
                { "CA", "82", "C9", "7D", "FA", "59", "47", "F0", "AD", "D4", "A2", "AF", "9C", "A4", "72", "C0" },
                { "B7", "FD", "93", "26", "36", "3F", "F7", "CC", "34", "A5", "E5", "F1", "71", "D8", "31", "15" },
                { "04", "C7", "23", "C3", "18", "96", "05", "9A", "07", "12", "80", "E2", "EB", "27", "B2", "75" },
                { "09", "83", "2C", "1A", "1B", "6E", "5A", "A0", "52", "3B", "D6", "B3", "29", "E3", "2F", "84" },
                { "53", "D1", "00", "ED", "20", "FC", "B1", "5B", "6A", "CB", "BE", "39", "4A", "4C", "58", "CF" },
                { "D0", "EF", "AA", "FB", "43", "4D", "33", "85", "45", "F9", "02", "7F", "50", "3C", "9F", "A8" },
                { "51", "A3", "40", "8F", "92", "9D", "38", "F5", "BC", "B6", "DA", "21", "10", "FF", "F3", "D2" },
                { "CD", "0C", "13", "EC", "5F", "97", "44", "17", "C4", "A7", "7E", "3D", "64", "5D", "19", "73" },
                { "60", "81", "4F", "DC", "22", "2A", "90", "88", "46", "EE", "B8", "14", "DE", "5E", "0B", "DB" },
                { "E0", "32", "3A", "0A", "49", "06", "24", "5C", "C2", "D3", "AC", "62", "91", "95", "E4", "79" },
                { "E7", "C8", "37", "6D", "8D", "D5", "4E", "A9", "6C", "56", "F4", "EA", "65", "7A", "AE", "08" },
                { "BA", "78", "25", "2E", "1C", "A6", "B4", "C6", "E8", "DD", "74", "1F", "4B", "BD", "8B", "8A" },
                { "70", "3E", "B5", "66", "48", "03", "F6", "0E", "61", "35", "57", "B9", "86", "C1", "1D", "9E" },
                { "E1", "F8", "98", "11", "69", "D9", "8E", "94", "9B", "1E", "87", "E9", "CE", "55", "28", "DF" },
                { "8C", "A1", "89", "0D", "BF", "E6", "42", "68", "41", "99", "2D", "0F", "B0", "54", "BB", "16" }
        };

        private string[,] SBOX_Inverse =
        {
                { "52", "09", "6a", "d5", "30", "36", "a5", "38", "bf", "40", "a3", "9e", "81", "f3", "d7", "fb" },
                { "7c", "e3", "39", "82", "9b", "2f", "ff", "87", "34", "8e", "43", "44", "c4", "de", "e9", "cb" },
                { "54", "7b", "94", "32", "a6", "c2", "23", "3d", "ee", "4c", "95", "0b", "42", "fa", "c3", "4e" },
                { "08", "2e", "a1", "66", "28", "d9", "24", "b2", "76", "5b", "a2", "49", "6d", "8b", "d1", "25" },
                { "72", "f8", "f6", "64", "86", "68", "98", "16", "d4", "a4", "5c", "cc", "5d", "65", "b6", "92" },
                { "6c", "70", "48", "50", "fd", "ed", "b9", "da", "5e", "15", "46", "57", "a7", "8d", "9d", "84" },
                { "90", "d8", "ab", "00", "8c", "bc", "d3", "0a", "f7", "e4", "58", "05", "b8", "b3", "45", "06" },
                { "d0", "2c", "1e", "8f", "ca", "3f", "0f", "02", "c1", "af", "bd", "03", "01", "13", "8a", "6b" },
                { "3a", "91", "11", "41", "4f", "67", "dc", "ea", "97", "f2", "cf", "ce", "f0", "b4", "e6", "73" },
                { "96", "ac", "74", "22", "e7", "ad", "35", "85", "e2", "f9", "37", "e8", "1c", "75", "df", "6e" },
                { "47", "f1", "1a", "71", "1d", "29", "c5", "89", "6f", "b7", "62", "0e", "aa", "18", "be", "1b" },
                { "fc", "56", "3e", "4b", "c6", "d2", "79", "20", "9a", "db", "c0", "fe", "78", "cd", "5a", "f4" },
                { "1f", "dd", "a8", "33", "88", "07", "c7", "31", "b1", "12", "10", "59", "27", "80", "ec", "5f" },
                { "60", "51", "7f", "a9", "19", "b5", "4a", "0d", "2d", "e5", "7a", "9f", "93", "c9", "9c", "ef" },
                { "a0", "e0", "3b", "4d", "ae", "2a", "f5", "b0", "c8", "eb", "bb", "3c", "83", "53", "99", "61" },
                { "17", "2b", "04", "7e", "ba", "77", "d6", "26", "e1", "69", "14", "63", "55", "21", "0c", "7d" }
        };

        private string[,] Rcon =
        {
            {"01", "00", "00", "00" },
            {"02", "00", "00", "00" },
            {"04", "00", "00", "00" },
            {"08", "00", "00", "00" },
            {"10", "00", "00", "00" },
            {"20", "00", "00", "00" },
            {"40", "00", "00", "00" },
            {"80", "00", "00", "00" },
            {"1b", "00", "00", "00" },
            {"36", "00", "00", "00" },
        };

        public List<string[]> Wlist = new List<string[]>();
        /*--------------------------------------------------------------------------------------------*/
        /*Enkrisi proses*/
        /*Proses SubByte S-Box**/

        private string [, ] SubByte (string[, ] x)
        {
            for (int i=0; i<=x.GetLength(0);i++)
            {
                for (int j=0; i<=x.GetLength(1)-1; i++)
                {
                    if (x[i,j].Length==1)
                    {
                        x[i, j] = SBOX_SubByte[0, ConversiClass.Hextodecimal(x[i, j][0].ToString())];
                    }
                    else
                    {
                        x[i, j] = SBOX_SubByte[ConversiClass.Hextodecimal(x[i, j][0].ToString()), ConversiClass.Hextodecimal(x[i,j] [1].ToString())];
                    }
                }
            }
            return x;
        }
        /*--------------------------------------------------------------------------------------------*/
        /*Proses SHiftRows**/

        private string [, ] ShiftRows (string [,] x)
        {
            string[,] tmp = new string[x.GetLength(0), x.GetLength(0)];
            for (int i = 0; i<=x.GetLength(0)-1;i++)
            {
                int pos = i;

                for (int j=0; j<=x.GetLength(0)-1;j++)
                {
                    tmp[i, j] = x[i, pos];
                    if (pos==3)
                    {
                        pos = 0;
                    }
                    else
                    {
                        pos += 1;
                    }
                }
            }
            return tmp;
        }

        /*--------------------------------------------------------------------------------------------*/

        /*geser kiri Initial Permutation**/
        private int ShiftLift (string x)
        {
            string tmp = ConversiClass.HexaToBiner(x);
            return ConversiClass.BinnerToDecimal(tmp.Substring(1)+tmp.Substring(0,1));
        }

        /*--------------------------------------------------------------------------------------------*/

        /*Proses Initial Permutation**/
        private string[,] InputPermutation =  {
            { "58", "50", "42", "34", "26", "18", "10", "2" },
            { "60", "52", "44", "36", "28", "20", "12", "4" },
            { "62", "54", "46", "38", "30", "22", "14", "6" },
            { "64", "56", "48", "40", "32", "24", "16", "8" },
            { "57", "49", "41", "33", "25", "17", "9", "1" },
            { "59", "51", "43", "35", "27", "19", "11", "3" },
            { "61", "53", "45", "37", "29", "21", "13", "5" },
            { "63", "55", "47", "39", "31", "3", "15", "7" },
            { "116", "100", "84", "68", "52", "36", "20", "4" },
            { "120", "104", "88", "72", "56", "40", "24", "8" },
            { "124", "108", "92", "76", "60", "44", "28", "12" },
            { "128", "112", "96", "80", "64", "48", "32", "16" },
            { "114", "98", "82", "66", "50", "34", "18", "2" },
            { "118", "102", "86", "70", "54", "38", "22", "6" },
            { "122", "106", "90", "74", "58", "42", "26", "10" },
            { "126", "110", "94", "78", "62", "46", "30", "14" }

        };

        private string[, ] InversePermutation = {
            { "40", "8", "48", "16", "56", "24", "64", "32" },
            { "39", "7", "47", "15", "55", "23", "63", "31" },
            { "38", "6", "46", "14", "54", "22", "62", "30" },
            { "37", "5", "45", "13", "53", "21", "61", "29" },
            { "36", "4", "44", "12", "52", "20", "60", "28" },
            { "35", "3", "43", "11", "51", "19", "59", "27" },
            { "34", "2", "42", "10", "50", "18", "58", "26" },
            { "33", "1", "41", "9", "49", "17", "57", "25" },
            { "80", "16", "96", "32", "112", "48", "128", "64" },
            { "78", "14", "94", "30", "110", "46", "126", "62" },
            { "76", "12", "92", "28", "108", "44", "124", "60" },
            { "74", "10", "90", "26", "106", "42", "122", "58" },
            { "72", "8", "88", "24", "104", "40", "120", "56" },
            { "70", "6", "86", "22", "102", "38", "118", "54" },
            { "68", "4", "84", "20", "100", "36", "116", "52" },
            { "66", "2", "82", "18", "98", "34", "114", "50" }
        };

        private string [, ] IP (string [,] x)
        {
            string[,] tmp = new string[x.GetLength(0), x.GetLength(0)];
            int k = 58;
            for (int i=0;i<=x.GetLength(0)-1;i++)
            {
                int pos = i;
            }
            return tmp;
        }


    }
}
Posted
Updated 21-Jun-19 20:28pm

1 solution

No, not if your code is that poor!
Just looking at the first bit gives me chills and shows that your code is completely untested:
public string [] CipherText2
{
    get
    {
        return CipherText2;
    }
    set
    {
        cipherText2 = value;
    }
}
Try this code and see what happens:
C#
cryptografi cg = new cryptografi();
string[] arr = cg.Ciphertext2;

It won't be pretty...

And the spelling errors in you naming, your lack of naming conventions, the total absence of any commenting or self documentation doesn't incline me to wade through the rest to work out what you may or may not have done so far.
Sort your code out, test what you have, and then come back and explain what help you need. A generic code dump and "help me to make the program" is very unlikely to get you anywhere.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900