[C#] How To Make A Semi-Advanced Encryption System

Hi all im back and today ill show you how to make a basic Encryption key for a basic cipher that i mad a while back.

we will be using these dll’s. we don’t need any but Exception`s are helpful.

using System; // not needed 

For making the Encryption key we will need 2 things a list of letters and symbols to use

private char[] alphabet = new char[]
        {
            'q','w','e','r','t','z','u','i','o','p','a','s','d','f','g',
            'h','j','k','l','y','x','c','v','b','n','m','Q','W','E','R',
            'T','Z','U','I','O','P','A','S','D','F','G','H','J','K','L',
            'Y','X','C','V','B','N','M','1','2','3','4','5','6','7','8',
            '9','!','"','§','$','%','&','/','(',')','=','?','ß','´','`',
            '²','³','{','[',']','}','^','°','<','>','|','µ',',',';','.',
            ':','-','_','ö','ä','ü','Ö','Ä','Ü','+','*','~','#','€',' ',
            '0'
        };// all keys on qwertz (german) keyboard

And a thew helpful methods (functions).

private int GET_LETTER_NUM(char letter,char[] alphabet)
        {
            for (int x = 0; x < alphabet.Length; x++)
            {
                if (letter == alphabet[x]) { return x; }
            }
            throw new Exception("unknown letter/symbol: " + letter + ToString());
        }//gets the position in alphabet for that letter

        private int SpecialFormulaONE(int DividingNumber, int number)
        {
            int length = number;
            while (number > -100000)
            {
                if (number > DividingNumber)
                {
                    number = number - DividingNumber;
                }
                else
                {
                    if (number == DividingNumber)
                    {
                        number--;
                    }
                    return number;
                }
            }
            throw new Exception("SpecialFormulaONE failure");
        }//i made this to replace % (get dividing remainder)

now for making the actual Encryption key

public string[] GET_KEY(string key, char[] alphabet)//key is the password input
        {
            if (key.Length < 16)
            {
                throw new Exception("too small a key");
            }
            char[] input = key.ToCharArray();
            int length = input.Length;
            char first_letter = input[0];
            char last_letter = input[length - 1];
            string[] END = new string[alphabet.Length];


            //start of encryption process
            {
                //1 E_KEY cell per Letter in Alphabet
                for (int x = 0; x < alphabet.Length; x++)//1 E_KEY cell = 4 alphabet letter
                {
                    string cell = "";
                    for (int y = 0; y < 4; y++)
                    {

                        int end = 0;
                        for (int z = 0; z < length; z++)
                        {
                            int offset = (x * y * z) + length;
                            end += GET_LETTER_NUM(input[z],alphabet) + offset;
                        }
                        cell += alphabet[SpecialFormulaONE(alphabet.Length, end)].ToString();

                    }
                    END[x] = cell;
                }
            }

            return END;
        }//creates a key
3 Likes

I cant understand , this functions , if we pass a sample text like : “hello im asking a question” to the get_key function with alphabet array
it will return this text:

((((.(²°…(°Öt.(.tm.(ÖlX.(€U/.(tX;.(s9r.(ln.(m;Y.(U#&.(Fa,.(Xne.(2Db.(91L.(/&%.(}µ.(^äw.(;ev.(üjK.(#T$.(rL|.(a70.(kßc.(nµJ.(Z*§.(Do>.(Yv0.(1Ax.(8NH.(&$".(´[<.(}_ .(,0y.(ägG.(~E!.(eJ°.(p5€.(j=l.(b>F.(TÜ9.(Su^.(Lx#.(MOk.(7VD.(%"8.(ß³}.(]:~.(µ j.(ödS.(Q7.(wG].(o3.(h(h.(v°A.(RÖ6.(At[.(Kl+.(NUg.(6XP.($95.(?{.([;Ü.(|#f.(aO.(+n4.(0D³.(i1Ä.(g&d.(c}I.(Eä3.(Pe².(JjÖ.(BTs.(5LU.(§72.(=ß.({µü.(>*a.(-oZ.(Üv1.(0A´.(uNä.(f$p.(x[T.(W_M.(O0ß.(Hgö.(VEo.(4JR.("5N.()=?.(³>.(<Üi.(:uE.(ÄxB.( O=.(zV-.(d"u.(y³W.(Q:V.(I ).(Gd:.(CQz.(3GQ.(!3C.

Do I Using this code in a rightway ?

Hi and welcome the 0x00sec community!
Before trying to answer your question, I would like you to read oaktree’s post adherency guidelines and the Markdown Cheatsheet.
Please help us to help you and reformat your post! :slight_smile:
Thanks! SmartOne

2 Likes

What a blast from the past!

2 Likes