How to Make Sure You Have Good Passwords

  • Comments posted to this topic are about the content posted at

    ___the truth is out there___

  • Great article!

    Here are a couple ways to check to make sure there is a mix of upper and lower case letters.

    Use the LOWER function. This only ensures that there is at least one upper case character. Use like this:

    if @password = LOWER (@password)

        -- Password has no upper-case characters

    If you want to count how many of each character type, include this in your function/procedure (Assumes a string variable @password is passed in):

    declare @lowerCount int

    declare @upperCount int

    declare @numberCount int

    declare @specialCount int

    declare @currentIndex int

    declare @currentCharAscii int

    set @currrentIndex = 0

    while @currIndex < LEN (@password)


        @currentCharAscii = ASCII (SUBSTRING (@password, @currentIndex, 1))

        if @currentCharAscii between 97 and 122 set @lowerCount = @lowerCount + 1

        if @currentCharAscii between 65 and 90 set @upperCount = @upperCount + 1

        if @currentCharAscii between 48 and 57 set @numberCount = @numberCount + 1


    set @specialCount = LEN (@password) - @lowerCount - @upperCount - @numberCount

    -- Check your rules

    You might need to debug typing errors in the code snippet since I did not actually write it in QA (I don't have SQL Server tools on this computer) but the logic should be right.

    [font="Tahoma"]Bryant E. Byrd, BSSE MCDBA MCAD[/font]
    Business Intelligence Administrator
    MSBI Administration Blog

  • Don't forget sp_change_user_login

  • I understand why passwords need to be difficult to figure out.  I also understand that making passwords complex makes them more difficult to figure out programmatically.  The dilemma I have with complex passwords (and non-complex passwords that have to be changed every month or so), is that the minute you (and everyone else who wants their site passwords to be secure) start requiring these type of passwords, users have no choice but to write them down somewhere.

    So I thought this article was very helpful given the premise that passwords need to be complex.  I would, however, like to see an article that addresses how to keep passwords secure when they're kept in a folder, or an Excel spreadsheet, or an Outlook folder called 'my passwords'.

  • After further thought and reviewing your code I realized you left one area out that should be addressed.

    You check to make sure password and login don't match but you should make sure the login does not exist in the password.

    For instance it is consider a weak password if I do something like so.

    Login: BobSmtih

    Password: BobSmith123

    Use Charindex to look for bobsmith in the password string and if return > 0 it was found, password is bad.

    Just a suggestion.

  • As I said in some reply to a password issue on this forum earlier, strong passwords are at least 15 characters long and it doesn't matter much if there are uppercase and lowercase letters and special characters mixed. Putting special characters in the middle of password may give you some edge for your monitoring software to discover attackers while the password problem is more complex for software like Bruteforce.

    To my knowledge the cheapest software (freeware) give up the pasword cracking task when password length is 14 chars long and to be on the safe side use always at least 15 characters with passwords.

    The "easy to remember password requirements" chapter is good when the length is raised to 15 chars and one should use a password sentence instead of a password.

    By the way this is a very good password for sa :

    DECLARE @pass char(72)

    SELECT @pass=convert(char(36),newid())+convert(char(36),newid())

    EXECUTE master..sp_password null,@pass,'sa'


    Why..? Well, where do you need sa's password, nowhere.

    Don't work easy, work safe.

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply