Return to Snippet

Revision: 35389
at November 6, 2010 11:35 by sambou


Initial Code
public bool ComparePasswords(string OldPassword, string NewPassword)
    {
        bool match4 = true;
        int diffCount = 0;
        ArrayList list = new ArrayList();
        string s = OldPassword;
        string t = NewPassword;

        for (int i = 0; i < s.Length; i++)
        {
            if (i >= t.Length)
            {
                break;
            }
            else if (s[i] != t[i])
            {
                diffCount++;
            }
            else if (s[i] == t[i])
            {
                diffCount = 0;
            }

            if (diffCount == 4)
            {
                match4 = false;
                break;
            }
        }

        return match4;
    }

Initial URL


Initial Description


Initial Title
Compare two password values to ensure that at least 4 characters have changed

Initial Tags


Initial Language
C#