Validate password so that it does not allow character repitition n times

So you want to make sure that your ascii password doesn’t haven any character recurring more than n times.

Here is what I came up with!

Unicoding…just increase your int array to accommodate!

static bool HasMultiple(string pass,int num)
{
var CharCheck = new int[256];
for (int x = 0; x < pass.Length; x++) {

if (CharCheck[pass[x]] > num-1)
{
return true;
}
else
{
CharCheck[pass[x]] ++;
}
}
return false;
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s