CFLib.org – Common Function Library Project

ccEscape(ccnum)

Last updated April 26, 2009

author

Joshua Miller

Version: 2 | Requires: CF5 | Library: StrLib

Description:
Escapes a credit card number, showing only the last 4 digits. The other digits are replaced with the * character.

Return Values:
Returns a string.

Example:

<cfset creditcard="4343010125259797">
<cfoutput>#ccEscape(creditcard)#</cfoutput>

Parameters:

Name Description Required
ccnum Credit card number you want to escape. Yes

Full UDF Source:

/**
 * Escapes a credit card number, showing only the last 4 digits. The other digits are replaced with the * character.
 * return just stars if str too short, found by Tony Monast
 * 
 * @param ccnum 	 Credit card number you want to escape. (Required)
 * @return Returns a string. 
 * @author Joshua Miller (josh@joshuasmiller.com) 
 * @version 2, April 26, 2009 
 */
function ccEscape(ccnum){
	if(len(ccnum) lte 4) return "****";
	return "#RepeatString("*",val(Len(ccnum)-4))##Right(ccnum,4)#";
}
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