In fact, I wish I could go back in time and unpublish it! While this version is definitely better, there is still room for improvement. #.net random password generator codeDue to many factors, that code was rushed and proved to be inefficient. " previous version of this class was intended for use in a much larger project (I will be publishing articles on various components of that project soon.). Private char pwdCharArray = " abcdefghijklmnopqrstuvwxyzABCDEFG" + This.maxSize = PasswordGenerator.DefaultMaximum This.minSize = PasswordGenerator.DefaultMinimum Generate random characters char lastCharacter, nextCharacter StringBuilder pwdBuffer = new StringBuilder() Pick random length between minimum and maximum int pwdLength = GetCryptographicRandomNumber( this.Minimum, PwdCharArray.GetLowerBound( 0), upperBound) Ĭhar randomChar = pwdCharArray Int randomCharPosition = GetCryptographicRandomNumber( UpperBound = PasswordGenerator.UBoundDigit Int upperBound = pwdCharArray.GetUpperBound( 0) Return ( int)(urndnum % (uBound-lBound)) + lBound Assumes lBound >= 0 & lBound = lBound and = xcludeRndBase) Protected int GetCryptographicRandomNumber( int lBound, int uBound)
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |