How do I encrypt passwords in such a way that it not only changes the characters of the password but also add extra characters. For example a password as "ABC" would become "12345" instead of "123". Another way is that for each character, the key shift is different. Below are my codes.
class CipherMachine
{
static private List<char> Charset =
new List<char>("PQOWIEURYTLAKSJDHFGMZNXBCV"
+ "olpikmujnyhbtgvrfcedxwszaq"
+ "1597362480"
+ "~!@#$%^&*()_+"
+ "PQOWIEURYTLAKSJDHFGMZNXBCV"
+ "olpikmujnyhbtgvrfcedxwszaq"
+ "1597362480"
+ "~!@#$%^&*()_+");
static private int Key = 39;
//static private int Length = 0;
static public string Encrypt(string plain)
{
string cipher = "";
foreach (char i in plain)
{
cipher += Charset.ElementAt(Charset.IndexOf(i) + Key);
//cipher += Charset.ElementAt(Charset.IndexOf(i) + Length);
}
return cipher;
}
static public string Decrypt(string cipher)
{
string plain = "";
foreach (char i in cipher)
{
plain += Charset.ElementAt(Charset.LastIndexOf(i) - Key);
//plain += Charset.ElementAt(Charset.LastIndexOf(i) - Length);
}
return plain;
}
}
}
Lines that are commented out are what I thought I could do but it turned out wrong.