ccEscape(ccnum)
Last updated April 26, 2009
Version: 2 | Requires: ColdFusion 5 | 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:
<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
Tayo Akinmade added
arrayTrim
3 day(s) ago
Will Belden added
longTime
9 day(s) ago
James Sleeman added
quickSort
19 day(s) ago
Ben Forta added
GetHostAddress
22 day(s) ago
Top Rated
EksporSQLData
Rated 5.0, 16 time(s)
backupDatabase
Rated 5.0, 13 time(s)
indentXml
Rated 5.0, 10 time(s)
generateSsccAsn
Rated 5.0, 4 time(s)