README.md
December 4, 2022 ยท View on GitHub
Description
These functions allow you to easily convert a string to its hex value and back again.
More Info
| Submitted On | |
| By | Lewis E. Moten III |
| Level | Beginner |
| User Rating | 5.0 (20 globes from 4 users) |
| Compatibility | ASP (Active Server Pages) |
| Category | Strings |
| World | ASP / 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