Technical Article

Strong Password Validation

,

This Script is used to validate the given string is password complince(i.e Strong Password) or not.

Allows [A-Z] or [a-z] or [0-9] or [,(,~,!,@,$,%,*,{,},?,),].

String need to have one character, 1 number and 1 specified special character.

declare @UserAccessKey as varchar(50)

set @UserAccessKey='asdf123qq'

declare @errorcode as int

declare @errordesc as varchar(200)

IF @UserAccessKey like '%[<>^ =#&`\/]%'

Begin

            Set @ErrorCode = 1

            Set @ErrorDesc = 'Useraccesskey should not contain < > # & characters.'

            GOTO ERRORHANDLER           

End

IF NOT (@UserAccessKey like '%[0-9]%'

            AND @UserAccessKey like '%[a-z]%'

            AND @UserAccessKey like '%[(~!@$%*{}?)]%')

Begin

            Set @ErrorCode = 2

            Set @ErrorDesc = 'Useraccesskey should be a strong password value.'

            GOTO ERRORHANDLER           

End

ErrorHandler:

print @ErrorCode

print @errordesc

Rate

You rated this post out of 5. Change rating

Share

Share

Rate

You rated this post out of 5. Change rating