1

I have 16 bytes string which im shifting left, after i shift it left, im trying to display result in RichTextbox:

Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
    Dim positiveString As String = "00082B002C421A21B630B934B7B71C9A99"
    Dim posBigInt As BigInteger = 0
    posBigInt = BigInteger.Parse(positiveString, System.Globalization.NumberStyles.AllowHexSpecifier)
     posBigInt = (posBigInt << 1)
    RichTextBox1.Text = Hex(posBigInt.ToString)
End Sub
Public Function StrToHex(ByRef Data As String) As String
    Dim sVal As String
    Dim sHex As String = ""
    While Data.Length > 0
        sVal = Conversion.Hex(Strings.Asc(Data.Substring(0, 1).ToString()))
        Data = Data.Substring(1, Data.Length - 1)
        sHex = sHex & sVal
    End While
    Return sHex
End Function

StrToHex function gives me wrong output, and if i try Hex(posBigInt.ToString) gives me correct output, if value fits up to uint64, therefore Hex() cant fit biginterger

James_BK
  • 21
  • 1
  • 7

1 Answers1

0

Seems like this ("X") do the thing:

RichTextBox1.Text = posBigInt.ToString("X")

Found it on c# thread about biginterger: BigInteger to Hex/Decimal/Octal/Binary strings?

James_BK
  • 21
  • 1
  • 7
  • it outputs "082B002C421A21B630B934B7B71C9A99" so it skips first 00,maybe someone knows how to handle it? – James_BK Jul 04 '18 at 05:04
  • The first `00` doesn't make a difference for the actual number, so that's why they're not included. You can prepend how many zeros you want, they still won't change anything. Why include something that doesn't make a difference being there? :) – Visual Vincent Jul 04 '18 at 09:01
  • @VisualVincent i have an issue with that code, im update qeustion, can you be so kind to have a look at it? – James_BK Jul 04 '18 at 09:33
  • Actaully ill create new topic – James_BK Jul 04 '18 at 09:34