Click here to Skip to main content
15,891,881 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi everyone my Company ordered me to create program for Time attendance we have program working but this application for IT company this company finished and we have no connection to them for technical support so I programmed program like that the problem I faced is password login it is saved in database encrypted when I log as user i should log for encrypted password i look for function used to encrypt password in .net reflector after I open IT company application but i do not understand strings I look for Strings I could not understand simply when i enter password like 0 the encrypted password will be 8 and here is the function used for IT company application I hope to help me .

C#
 public static string CodingPasswordFun(string OldStr)
{
    string str2;
    string str3;
    string str4;
    string str5;
    string str6;
    int num2;
    int num3 = Strings.Len(OldStr);
    for (num2 = 1; num2 <= num3; num2++)
    {
        str5 = Strings.Mid(OldStr, num2, 1);
        str2 = str2 + str5;
        if (num2 == 2)
        {
            str2 = str2 + "A";
        }
        else if (num2 == 4)
        {
            str2 = str2 + "D";
        }
        else if (num2 == 6)
        {
            str2 = str2 + "E";
        }
        else if (num2 == 8)
        {
            str2 = str2 + "L";
        }
    }
    int num4 = Strings.Len(str2);
    for (int i = 1; i <= num4; i++)
    {
        str5 = Strings.Mid(str2, i, 1);
        str6 = str6 + str5;
        switch (i)
        {
            case 3:
                str6 = str6 + "B";
                break;

            case 5:
                str6 = str6 + "E";
                break;

            case 7:
                str6 = str6 + "T";
                break;

            case 9:
                str6 = str6 + "A";
                break;
        }
    }
    int num5 = Strings.Len(str6);
    for (num2 = 1; num2 <= num5; num2++)
    {
        string str8 = Strings.Mid(str6, num2, 1);
        str4 = str4 + Conversions.ToString(Strings.Asc(str8));
    }
    int num6 = Strings.Len(str4);
    for (num2 = 1; num2 <= num6; num2++)
    {
        if ((num2 % 2) == 0)
        {
            string str7 = Strings.Mid(str4, num2, 2);
            if ((((Conversions.ToDouble(str7) >= 65.0) & (Conversions.ToDouble(str7) <= 90.0)) | ((Conversions.ToDouble(str7) >= 97.0) & (Conversions.ToDouble(str7) <= 122.0))) | (Conversions.ToDouble(str7) == 45.0))
            {
                str3 = str3 + Conversions.ToString(Strings.Chr(Conversions.ToInteger(str7)));
            }
            else
            {
                str3 = str3 + str7;
            }
        }
    }
    return str3;
}


What I have tried:

C#
 public static string CodingPasswordFun(string OldStr)
{
    string str2;
    string str3;
    string str4;
    string str5;
    string str6;
    int num2;
    int num3 = Strings.Len(OldStr);
    for (num2 = 1; num2 &lt;= num3; num2++)
    {
        str5 = Strings.Mid(OldStr, num2, 1);
        str2 = str2 + str5;
        if (num2 == 2)
        {
            str2 = str2 + "A";
        }
        else if (num2 == 4)
        {
            str2 = str2 + "D";
        }
        else if (num2 == 6)
        {
            str2 = str2 + "E";
        }
        else if (num2 == 8)
        {
            str2 = str2 + "L";
        }
    }
    int num4 = Strings.Len(str2);
    for (int i = 1; i &lt;= num4; i++)
    {
        str5 = Strings.Mid(str2, i, 1);
        str6 = str6 + str5;
        switch (i)
        {
            case 3:
                str6 = str6 + "B";
                break;

            case 5:
                str6 = str6 + "E";
                break;

            case 7:
                str6 = str6 + "T";
                break;

            case 9:
                str6 = str6 + "A";
                break;
        }
    }
    int num5 = Strings.Len(str6);
    for (num2 = 1; num2 &lt;= num5; num2++)
    {
        string str8 = Strings.Mid(str6, num2, 1);
        str4 = str4 + Conversions.ToString(Strings.Asc(str8));
    }
    int num6 = Strings.Len(str4);
    for (num2 = 1; num2 &lt;= num6; num2++)
    {
        if ((num2 % 2) == 0)
        {
            string str7 = Strings.Mid(str4, num2, 2);
            if ((((Conversions.ToDouble(str7) &gt;= 65.0) &amp; (Conversions.ToDouble(str7) &lt;= 90.0)) | ((Conversions.ToDouble(str7) &gt;= 97.0) &amp; (Conversions.ToDouble(str7) &lt;= 122.0))) | (Conversions.ToDouble(str7) == 45.0))
            {
                str3 = str3 + Conversions.ToString(Strings.Chr(Conversions.ToInteger(str7)));
            }
            else
            {
                str3 = str3 + str7;
            }
        }
    }
    return str3;
}
Posted
Updated 18-Sep-17 16:42pm
Comments
ZurdoDev 18-Sep-17 15:38pm    
This does not look like true encryption but rather just changing characters around. What are you asking us?
Techno- Byte 18-Sep-17 15:45pm    
I am asking to help me to encrypt password if i enter 0 the encrypted will be 8
ZurdoDev 18-Sep-17 16:28pm    
There are tons of examples online, so how can we help?
Dave Kreskowiak 18-Sep-17 16:03pm    
Is this for a serious, production application or are you just playing around with a Caesar Cipher[^]? That's not serious encryption you should be using today.

You really don't even encrypt passwords. You use a cryptographic Hash on them and store the hash, NEVER the passwords themselves.
Richard MacCutchan 19-Sep-17 4:31am    
Your code is still not secure. Follow the link provided by Graeme Grant below and learn how to manage your passwords properly.

1 solution

This Google Search link gives you many different ways to do what you are asking: c# password encryption 2017 - Google Search[^]

Choose the one that gives your client the security that they need.
 
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