package main type PasswordRestrictions struct { name string longName string minLength int maxLength int alphaLowerMin int alphaLowerMax int alphaUpperMin int alphaUpperMax int numberMin int numberMax int specialMin int specialMax int allowedSpecial string additionalRequirements func(string) (bool, int) //returns the index of the problem character } var sites []PasswordRestrictions = []PasswordRestrictions{ PasswordRestrictions{ name: "etrade", longName: "E-trade: etrade.com", minLength: 6, maxLength: 32, alphaLowerMin: 0, alphaLowerMax: 32, alphaUpperMin: 0, alphaUpperMax: 32, numberMin: 1, numberMax: 32, specialMin: 0, specialMax: 0}, PasswordRestrictions{ name: "fidelity", longName: "Fidelity Netbenefits", minLength: 6, maxLength: 12, alphaLowerMin: 0, alphaLowerMax: 12, alphaUpperMin: 0, alphaUpperMax: 12, numberMin: 0, numberMax: 12, specialMin: 0, specialMax: 0}, PasswordRestrictions{ name: "bbt", longName: "BB&T Banking", minLength: 8, maxLength: 12, alphaLowerMin: 0, alphaLowerMax: 12, alphaUpperMin: 0, alphaUpperMax: 12, numberMin: 1, //There is no max requirement on numbers, but we must have at least one //letter (either uppercase or lowercase) so putting an upper bound on //numbers is easier than an either-or lower bound on letters numberMax: 11, specialMin: 0, specialMax: 0, additionalRequirements: func(pass string) (bool, int) { if len(pass) < 1 { return true, 0 } for i := 1; i < len(pass); i++ { if pass[i-1:i] == pass[i:i+1] { return false, i } } return true, 0 }}, }