CFLib.org – Common Function Library Project

stringToHex(str)

Last updated May 8, 2006
Download UDF

author

Chris Dary                                        Chris Dary

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

 
Rated 0 time(s). Average Rating: 0

Description:
Counterpart to HexToString - converts an ASCII string to hexadecimal.

Return Values:
Returns a string.

Example:

<cfoutput>#stringToHex("hello")#</cfoutput>

Parameters:

Name Description Required
str String to convert to hex. Yes

Full UDF Source:

<cfscript>
/**
* Counterpart to HexToString - converts an ASCII string to hexadecimal.
*
* @param str      String to convert to hex. (Required)
* @return Returns a string.
* @author Chris Dary (umbrae@gmail.com)
* @version 1, May 8, 2006
*/

function stringToHex(str) {
    var hex = "";
    var i = 0;
    for(i=1;i lte len(str);i=i+1) {
        hex = hex & right("0" & formatBaseN(asc(mid(str,i,1)),16),2);
    }
    return hex;
}
</cfscript>

Search CFLib.org


Latest Additions

Shawn Porter Shawn Porter added
DeMoronize
3 hour(s) ago

Chris Carey Chris Carey added
readPropertiesFi...
1 day(s) ago

Randy Johnson Randy Johnson added
lastDayofWeek
3 day(s) ago

Frank Marion Frank Marion added
sitemapPing
7 day(s) ago

Top Rated

James Sleeman                                     QuickSort
Rated 5.0, 3 time(s)

Barney Boisvert indentXml
Rated 5.0, 3 time(s)

Nathan Dintenfass                                 queryColumnsToSt...
Rated 5.0, 3 time(s)

Kevin Pepperman generateSsccAsn
Rated 5.0, 3 time(s)

Created by Raymond Camden / Design by Justin Johnson