README.md

December 4, 2022 ยท View on GitHub

Hex/String Conversion

Description

These functions allow you to easily convert a string to its hex value and back again.

More Info

Submitted On
ByLewis E. Moten III
LevelBeginner
User Rating5.0 (20 globes from 4 users)
CompatibilityASP (Active Server Pages)
CategoryStrings
WorldASP / VbScript
Archive File

API Declarations

Copyright (c) 2001, Lewis Moten. All rights reserved.

Source Code

email = "lewis@moten.com" Response.Write "Original value: " & email & "
" email = StringToHex(email) Response.Write "Hex value: " & email & "
" email = HexToString(email) Response.Write "Back to string value: " & email & "
" Function StringToHex(ByRef pstrString) Dim llngIndex Dim llngMaxIndex Dim lstrHex llngMaxIndex = Len(pstrString) For llngIndex = 1 To llngMaxIndex lstrHex = lstrHex & Right("0" & Hex(Asc(Mid(pstrString, llngIndex, 1))), 2) Next StringToHex = lstrHex End Function Function HexToString(ByRef pstrHex) Dim llngIndex Dim llngMaxIndex Dim lstrString llngMaxIndex = Len(pstrHex) For llngIndex = 1 To llngMaxIndex Step 2 lstrString = lstrString & Chr("&h" & Mid(pstrHex, llngIndex, 2)) Next HexToString = lstrString End Function