Click here to monitor SSC

John Magnabosco

SQL Server Development and Data Security

Strong Password Generator

Published Wednesday, September 30, 2009 5:21 AM

Frank, the DBA, has been asked to create a series of passwords that will be used to protect a collection of symmetric keys. These keys will in turn be used to protect some sensitive data in a database.

Frank knows that the expectation is that these passwords will need to be strong passwords. Using the names of his cat's new born litter will not suffice. He made that mistake at his last job. Reviewing his notes to remind himself of the definition of a strong password he identifies the following:

1) The length of the password must be 8 characters or greater.
2) Does not include a series of letters that make a word or phrase.
    For example: "Password", "BettyIsHot", "FrankRocks".
3) The series of passwords that will be created are not sequential.
    For example:  "Password1", "Password2", "Password3".
4) Contains a variety of characters including uppercase letters, lowercase letters,
    numeric values and special characters.

With a sigh, Frank makes his first attempt at his series of passwords. It wasn't long until his human nature creped in and his so-called random series of characters didn't appear as random they should be. The injection of significant dates (08131969, 12071941 and 05291453), his favorite bands (U2, UB40 and B52s) and pseudo-words (M0V31T, R4d1c@L and P@sSw0rd) kept sneaking in.

After a few minutes of contemplation, a bag of beef jerky and a bottle of Yoo-Hoo, inspiration descended upon Frank like a Marcel Duchamp painting. He opened Management Studio and began typing furiously. The result was the following T-SQL script that assembles a series of characters in a loop that ultimately produces a strong password:

-- Variables
DECLARE @PassLen int; 
DECLARE @Pass varchar(50);
DECLARE @LoopCt int;
DECLARE @Rnd int;

-- Password length
SET @PassLen = 10;
-- Starting value of password
SET @Pass = '';
-- Starting value of loop
SET @LoopCt = 1;

-- Loop to generate the password 
WHILE @LoopCt <= @PassLen
    BEGIN
        -- Generate a random number to select a character
        SET @Rnd = Convert(int,(1 + RAND() * (9-1)));

        -- Build the password using the selected character
        SELECT @Pass = @Pass +
            CASE 
                -- This option is weighted

                WHEN @Rnd >=1 AND @Rnd <=3 THEN
                    -- a-z  
                   CHAR(Convert(int,(97 + RAND() * (122-97))))
                 -- This option is weighted
                WHEN @Rnd >=4 AND @Rnd <=6 THEN
                    -- A-Z 
                   CHAR(Convert(int,(65 + RAND() * (90-65))))
                WHEN @Rnd = 7 THEN
                    -- 0-9 
                    CHAR(Convert(int,(48 + RAND() * (57-48))))
                ELSE
                    -- #$%& (Special Character)
                    CHAR(Convert(int,(35 + RAND() * (38-35))))
             END

       -- Advance the loop    
        SET @LoopCt = @LoopCt + 1;
    END            

-- Return the password
SELECT @Pass;

GO

In his code, Frank thought it wise to weight the uppercase and lowercase letters so that they would be selected more often than the numeric and special character to prevent the occurrence of passwords that look like "1234567%9#", "#$%&%$#%$1". A sampling of the passwords that Frank generated through this code are: DqOC0bPkqF, Q3t6%mQk%l, UAFdK%gvvq and Rrs#qm%#f$.

After a few executions of this code Frank completed his task at hand. He handed his list of generated passwords to Betty, the Junior DBA, to implement. The data was once again safe. Betty was happy to no longer see Frank's lame flirting attempts through passwords like "W1llUg02th3M0v1eZw1thM3?".

by Johnm

Comments

 

johnb said:

Have anyone tried a password manager which has this functionality included?
I have used many password programs in the past and Sticky Password is right up there with the best of them. It is very easy to use and saves much time by automatically filling in user name and password info. On top of that a built in password generator is icing on the cake.
October 1, 2009 2:06 AM
 

How to Create Strong Passwords to Protect Yourself From Hackers said:

October 8, 2009 2:00 AM
 

Durango Price Auto Parts Spark Plug Wires, 1999 Chevrolet Trailblazer Dodge Durango said:

May 21, 2010 2:46 AM
 

Chevrolet P20 Dvd Taillight, P2000 Aftermarket Battery Charger said:

May 21, 2010 1:32 PM
 

Mercedes Benz 260e Biography, 260e Motor Windshield Washer said:

May 21, 2010 1:44 PM
 

E550 Replacement Auto, E5500 Refurbished said:

May 21, 2010 9:00 PM
 

Buy 940 Will, Hp Deskjet 5940 Cartridge said:

May 21, 2010 10:51 PM
 

Super Swamper Ssr Pictures Tread Pattern, Ssr Automobile Chevrolet Trailblazer said:

May 21, 2010 11:12 PM
 

380slc Discount 2006, 380slc Fog Light Miele said:

May 22, 2010 5:26 AM
 

Stealth Factory Brake Rotors 3000gt, Stealth Body Kits Mitsubishi 3000gt Twin Turbo said:

May 22, 2010 1:15 PM
 

2300 Mazda B2300 Headlight Assembly, Used List 1994 Mazda B2300 said:

May 22, 2010 5:34 PM
 

Used Bmw 760li Sale Philadelphia, 545i Performance Chip Bmw 760li said:

May 22, 2010 7:44 PM
 

Mio C520 C220, Wholesale 1995 Mercedes Benz C220 said:

May 22, 2010 9:33 PM
 

Esteem Radiator Plastic Tanks Brake Caliper, Used Engine Suzuki Esteem Wagon - 443.myipgirl.com said:

May 22, 2010 11:10 PM
 

Bangkok Beverage Trade Model Ltd, Ltd Part Backup Soy Bean - 35.tgrconversions.com said:

May 23, 2010 2:31 AM
 

Mercedes Benz W124 400e, 300se 300sl 400e - 79.renters.ws said:

May 23, 2010 4:20 AM
 

L300 3 Problems Discount, L300 Sale Exterior Color - 37.tvshowzone.com said:

May 23, 2010 5:25 AM
 

Jeep Heater Door, Jeep Diesel Crate Engine - 339.unlockiphone30.net said:

May 23, 2010 6:26 AM
 

Sundance Body Parts Plymouth Prowler, Pb150 2nd Hand Plymouth Prowler - 224.cmanager.org said:

May 23, 2010 7:39 AM
 

Chevrolet Pcr1500 Suburban Bulb Dot And Sae Approved, Gmc R1500 Suburban Radiator Cooling Systems - 163.cmanager.org said:

May 23, 2010 1:12 PM
 

Cl600 Radiator Fit, Fit Acronyms - 331.myipgirl.com said:

May 23, 2010 1:23 PM
 

Patriot Boiler Appears, Jeep Patriot Air Intake - 289.luna-atra.net said:

May 24, 2010 9:31 AM
 

420sel Oem Cl55 Amg, 420sel Performance Mercedes - 339.mfbattle.com said:

May 24, 2010 11:35 AM
 

Mazda Mpv Dealers, Mpv Discount Replacement - 352.1fh.org said:

May 24, 2010 1:50 PM
 

190d Radiator Nissens Volvo 300td, Used Mercedes Benz 300td Parts Cl55 Amg - 272.tvshowzone.com said:

May 24, 2010 7:16 PM
 

Sienna 98 Catalytic Converter, Aftermarket Motors Toyota Sienna - 274.unlockiphone30.net said:

May 24, 2010 8:09 PM
 

Cordia Oem Accessories, Led Cordia Fog Lights - 469.myipgirl.com said:

May 25, 2010 3:58 AM
 

Gs400 Radiator Rx330 1992 Lexus Ls400, 1999 Lx470 Sale Golden Pearl Lexus Gs400 - 475.tijuanareader.com said:

May 25, 2010 4:46 PM
 

Comet Automotive 1964 Mercury, Used Asteroids Comets - 431.tgrconversions.com said:

May 25, 2010 7:47 PM
 

SMoyano said:

Thanks, I add some changes to force mix almost 3 groups of characters
November 16, 2011 8:18 PM
You need to sign in to comment on this blog

About Johnm

John Magnabosco manages the Data Services Group at one of the fastest growing companies in the United States. He is also a Co-Founder of the Indianapolis Professional Association for SQL Server (IndyPASS), Co-Founder of IndyTechFest, the author of the book titled "Protecting SQL Server Data" and contributing author of "SQL Server MVP Deep Dives Volume 2".
<September 2009>
SuMoTuWeThFrSa
303112345
6789101112
13141516171819
20212223242526
27282930123
45678910
How to Kill a Company in One Step or Save it in Three
 The majority of companies that suffer a major data loss subsequently go out of business. David Wesley... Read more...

Migrating from OCS 2007 R2 to Lync: Part 4
 Having migrated the rest of our users and legacy resources across, and start getting ready to... Read more...

Automated Script-generation with Powershell and SMO
 In the first of a series of articles on automating the process of building, modifying and copying SQL... Read more...

Seth Godin: Big in the IT Business
 Seth Godin has transformed our understanding of marketing in IT. He invented the concept of 'permission... Read more...

Using SQL Test Database Unit Testing with TeamCity Continuous Integration
 With database applications, the process of test and integration can be frustratingly slow because so... Read more...