CFLib.org – Common Function Library Project

pwStrength(pwString)

Last updated October 14, 2008

author

charlie griefer

Version: 1 | Requires: CF5 | Library: StrLib

Description:
Returns a structure that holds data used to check the strength of a user supplied password. keys include: string length number of alpha characters number of uppercase alpha characters number of lowercase alpha characters number of numeric characters number of bad (non alpha-numeric characters)

Return Values:
Returns a struct.

Example:

<cfset myStr = "dfWE2d %@ df4" />
<cfdump var="#pwStrength(myStr)#" />

Parameters:

Name Description Required
pwString String to check. Yes

Full UDF Source:

/**
 * Checks the strength of a user supplied password.
 * 
 * @param pwString 	 String to check. (Required)
 * @return Returns a struct. 
 * @author charlie griefer (charlie@griefer.com) 
 * @version 1, October 14, 2008 
 */
function pwStrength(pwString) {
	var retStruct = structNew();

	retStruct.originalString	= arguments.pwString;
	retStruct.originalLength	= len(arguments.pwString);
	retStruct.numericVals		= len(rereplace(pwString, '[^0-9]', '', 'all'));
	retStruct.alphas			= len(rereplaceNoCase(pwString, '[^a-z]', '', 'all'));
	retStruct.alphaUppers		= len(rereplace(pwString, '[^A-Z]', '', 'all'));
	retStruct.alphaLowers		= len(rereplace(pwString, '[^a-z]', '', 'all'));
	retStruct.badChars			= len(rereplace(pwString, '[\w]', '', 'all'));
	
	return retStruct;
}
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson