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)#";
}

Search CFLib.org


Latest Additions

Raymond Camden added
QueryDeleteRows
November 04, 2017

Leigh added
nullPad
May 11, 2016

Raymond Camden added
stripHTML
May 10, 2016

Kevin Cotton added
date2ExcelDate
May 05, 2016

Raymond Camden added
CapFirst
April 25, 2016

Created by Raymond Camden / Design by Justin Johnson