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;
CharCheck[pass[x]] ++;
return false;


Leave a Comment

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

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

Facebook photo

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

Connecting to %s