Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Revision on Byte to Hexadecimal
Message
De
03/02/2014 10:32:42
 
 
À
03/02/2014 10:06:05
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01592982
Message ID:
01593000
Vues:
31
>(1) I think you need to set a breakpoint on this and see what's the length of toByte
>
>(2) I have no idea why you are using System.Threading.Interlocked.Increment()

I have adjusted to this to remove the Interlocked. This came from an example on the Internet.
    ' Convert from byte to hexadecimal
    ' expO1 Byte
    Public Function ByteToHexadecimal(ByVal toByte As Byte()) As Boolean
        Dim llOK As Boolean = False
        Dim lnCounter As Integer = 0
        Dim lnLength As Integer = 0
        Dim loStringBuilder As StringBuilder = Nothing

        ' Reset the value
        cString = ""

        ' Initialization
        lnCounter = 0
        lnLength = toByte.Length

        ' The hexadecimal presentation is twice the size of the byte array, we have to multiply by 2
        loStringBuilder = New StringBuilder(lnLength * 2)

        Try

            ' For each byte
            For lnCounter = 0 To lnLength - 1
                loStringBuilder.AppendFormat("{0:X2}", toByte(lnCounter))
            Next

            llOK = True

        Catch loError As Exception
            cMessage = loError.Message
        End Try

        ' Initialization
        cString = loStringBuilder.ToString

        Return llOK
    End Function
However, this is just an adjustment to remove the Interlock. If I would cut the For/Next counter in half, this would work when I go from MD5 to string conversion but would cut in half the value stored in Binary(16).
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform