Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HEX to ASCII

Status
Not open for further replies.

Microbe

Programmer
Oct 16, 2000
607
AU
In an effort to kill off some spam by hiding email address from harvesters, I am progressively converting email addresses on web pages to HEX format. I am not sure it is foolproof, but it has to help...I hope :)

I have written a script that does the ASCII -> HEX conversion - no worries.

VBscript has a HEX() command to convert a decimal ASCII value to HEX, but is there a way (apart from writing the algorithm myself) to convert from HEX to decimal? Steve Davis
hey.you@hahaha.com.au
 
To the best of my knowledge, there is no built-in hex-decimal conversion methods. There may be a COM object that comes with windows, but I kind of doubt it. Most likely, you would be able to find the code on the web a little quicker than it would take to write it all out. As a matter of fact...


Function HexToDec(strHex)
dim lngResult
dim intIndex
dim strDigit
dim intDigit
dim intValue

lngResult = 0
for intIndex = len(strHex) to 1 step -1
strDigit = mid(strHex, intIndex, 1)
intDigit = instr("0123456789ABCDEF", ucase(strDigit))-1
if intDigit >= 0 then
intValue = intDigit * (16 ^ (len(strHex)-intIndex))
lngResult = lngResult + intValue
else
lngResult = 0
intIndex = 0 ' stop the loop
end if
next

HexToDec = lngResult
End Function


1.3 minutes of searching :)

Now, I have not tested or examined the code. Here's where I got it from, tho...


They also have dec -> bin and bin -> dec.

Hope this helps! ________________________________________
Michael C Flanakin
Indigo Web Systems
michael.flanakin@indigows.com
 
Doh...and here I am always telling people "use google" but it didn't even cross my mind.

Thanks for that. Steve Davis
hey.you@hahaha.com.au
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top