Converting String to String of Hex and vice-versa in Vb.Net -


i need convert string of totally random characters in can read back! idea is:

example string: hi

h (ascii) -> 68 (hex)  (ascii) -> 69 (hex) 

so converting hi must have 6869

my value in base64 (i got convert.tobase64string()), "ascii hex" conversion correct? in base64 have value "4kiw0uewc/+c=" need characters only, special characters can mess system

the vb.net convert can translate base64 string :(

edit: final solution: got base64 string inside enc variable , converted first in ascii in corrispondent hex using:

dim bytes byte() = system.text.encoding.ascii.getbytes(enc) dim hex string = bitconverter.tostring(bytes).replace("-", string.empty) 

after reversed with:

dim b((input.length \ 2) - 1) byte int32 = 0 b.getupperbound(0)      b(i) = byte.parse(input.substring(i * 2, 2), globalization.numberstyles.hexnumber) next dim enc new system.text.asciiencoding() result = enc.getstring(b) 

after got base64string , converted 1 last time convert.frombase64string(result)

done! hint :)

first byte() base64 string:

dim data = convert.frombase64string(inputstring) 

then use bitconverter:

string hex = bitconverter.tostring(data) 

Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -