-
ASCII to Base32
I have a arduino project that I am working on. I need the 10 characters changed from ASCII to Hex and Base32. I have the Hex working but I can not figure out how to convert to the Base32. Here is my code. I have been all overGoogle and I cannot find any clear answer. Any help or a point in the right direction would be great.
Code:
Private Sub Clear_Click(sender As Object, e As EventArgs) Handles Clear.Click
txtbox.Text = ""
arduino.Text = ""
Auth.Text = ""
End Sub
Private Sub Ok_Click(sender As Object, e As EventArgs) Handles Ok.Click
arduino.Text = "{" & String.Join(", ", txtbox.Text.Select(Function(c) String.Format("0x{0:X2}", Convert.ToInt32(c)))) & "}"
End Sub
End Class
-
Re: ASCII to Base32
I have updated my code to below but now I am getting this error.
Value of type 'String' cannot be converted to 'Byte()'. WindowsApplication2
Code:
Private Sub Ok_Click(sender As Object, e As EventArgs) Handles Ok.Click
arduino.Text = "{" & String.Join(", ", txtbox.Text.Select(Function(c) String.Format("0x{0:X2}", Convert.ToInt32(c)))) & "}"
Dim DataToEncode As Byte() = txtbox.Text
Dim Base32 As String
Base32 = DataToEncode.ToBase32String()
Auth.Text = Base32
End Sub
-
Re: ASCII to Base32
Yes you can not place a string in a byte, nor can you assign a string directly to a byte array. You can turn a string into a byte array which is what you would need to do there.
Have a look at the GetBytes method of the Encoding class
Example
Code:
sBytes = Encoding.Default.GetBytes(DataString)