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