CFLib.org – Common Function Library Project

ccEscape(ccnum)

Last updated April 26, 2009
Download UDF

author

Joshua Miller Joshua Miller

Version: 2 | Requires: ColdFusion 5 | Library: StrLib

 
Rated 2 time(s). Average Rating: 4.5

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:

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

Search CFLib.org


Latest Additions

Ryan Thompson-Jewell Ryan Thompson-Jewell added
ListSplit
2 day(s) ago

Nathan Dintenfass Nathan Dintenfass added
RowsToColumns
2 day(s) ago

Barney Boisvert Barney Boisvert added
indentXml
3 day(s) ago

Barney Boisvert Barney Boisvert added
REReplaceCallbac...
3 day(s) ago

Top Rated

Rob Brooks-Bilson                                 FolderSize
Rated 5.0, 7 time(s)

Nick Giovanni                                     UniqueValueList
Rated 5.0, 5 time(s)

James Sleeman                                     QuickSort
Rated 5.0, 3 time(s)

Jeff Howden ListDeleteDuplic...
Rated 5.0, 3 time(s)

Created by Raymond Camden / Design by Justin Johnson