×

Loading...
Ad by
  • 予人玫瑰,手有余香:加拿大新天地工作移民诚聘求职顾问&行业导师!
Ad by
  • 予人玫瑰,手有余香:加拿大新天地工作移民诚聘求职顾问&行业导师!

asp help: hex to string. I have a function to convert string to hex; but how can i do the opposite way. To convert hex back to string? thx.

<%
Public Function bu_Str2Hex(str)
' Converts string <str> of chars to string in hex byte format
' E.g. "abc" will be converted to "616263"
sHex = ""

n = Len(str)
For i = 1 To n
byt = CByte(Asc(Mid(str, i, 1)))
If Len(Hex(byt)) = 1 Then
sHex = sHex & "0" & Hex(byt)
Else
sHex = sHex & Hex(byt)
End If
Next
bu_Str2Hex = sHex

End Function


Str = "abc"
strHex = bu_Str2Hex(str)
%>

<html>
str: [<%= Str %>]<br>
hex: [<%= strHex %>]

</html>
Report

Replies, comments and Discussions:

  • 工作学习 / 专业技术讨论 / asp help: hex to string. I have a function to convert string to hex; but how can i do the opposite way. To convert hex back to string? thx.
    <%
    Public Function bu_Str2Hex(str)
    ' Converts string <str> of chars to string in hex byte format
    ' E.g. "abc" will be converted to "616263"
    sHex = ""

    n = Len(str)
    For i = 1 To n
    byt = CByte(Asc(Mid(str, i, 1)))
    If Len(Hex(byt)) = 1 Then
    sHex = sHex & "0" & Hex(byt)
    Else
    sHex = sHex & Hex(byt)
    End If
    Next
    bu_Str2Hex = sHex

    End Function


    Str = "abc"
    strHex = bu_Str2Hex(str)
    %>

    <html>
    str: [<%= Str %>]<br>
    hex: [<%= strHex %>]

    </html>
    • use Chr()
      • i have found the soluction. thx