×

Loading...
Ad by
  • 最优利率和cashback可以申请特批,好信用好收入offer更好。请点链接扫码加微信咨询,Scotiabank -- Nick Zhang 6478812600。
Ad by
  • 最优利率和cashback可以申请特批,好信用好收入offer更好。请点链接扫码加微信咨询,Scotiabank -- Nick Zhang 6478812600。

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