say I had a var
dim vHex as string
vHex = "&hhe" 'that's a hex code
vHextoInt = '?? ChangeHextoIntegerFunction ?? (vHex)
and I wanted to stuff it into a byte
dim vByteVar as Byte
vByteVar = Cbyte(vHextoInt)
How do I convert the Hex to Int??
Printable View
say I had a var
dim vHex as string
vHex = "&hhe" 'that's a hex code
vHextoInt = '?? ChangeHextoIntegerFunction ?? (vHex)
and I wanted to stuff it into a byte
dim vByteVar as Byte
vByteVar = Cbyte(vHextoInt)
How do I convert the Hex to Int??
Use CLng!
Simple as that! :rolleyes:Code:lblHex.Caption = CLng("&H12AB") ' Convert hexadecimal "12AB" to an integer
dim vTemp
vTemp = Clng("&h" & Mid(vKey, lCount * 2 + 1, 2))
doesn't fly, not even if you declare vTemp as an Integer
&hhe is a hex code right? or do you need 6 chars??
Well, actually &HHE isn't hex code.
&H means a hexadecimal number will follow. Hexadecimal numbers go from 0 to F. H isn't hex, so HE isn't also.
This encryption class is really irritating.
In theory it should be *cake* to use but I keep getting
0 byte files.
I even had it working earlier, I just re-wired the app the wrong way. I was trying to fix it by integrating the hex conversion of the key , which is what a sample frm tried to do but wouldn't compile.
I have sum tweaking to do..
Thanx
Val("&H12AB")Quote:
Originally posted by Yonatan
Use CLng!
Simple as that! :rolleyes:Code:lblHex.Caption = CLng("&H12AB") ' Convert hexadecimal "12AB" to an integer
Would work the same as CLng.
Oh yes, if you're converting characters to Hex I'd reccomend doing:
String2Hex = "Vb-World!"
for x = 1 to len(String2Hex)
NewHexStr = NewHexStr & format(hex$(asc(mid$(String2Hex,x,1))),"##00")
'format is to maintain 2 character hex REQUIRED for chr$(0-9)
next
and to bring it back:
Hex2String = "56622D576F726C6421"
for x = 1 to len(Hex2String) step 2
NewStr = NewStr & chr$(val("&H" & mid$(Hex2String,x,2)))
next x
unfortunately, I can't figure out how much crack the guy was smoking who did the sample form to show me how to use his vbClass
turns out - you need to compile the class into a dll, and then it will do long number addition without screwing it up.. i wasn't doing that.. also, he was trying to stuff
&h with two letters from your key
so if your key was zzzzzzzzzzzzzzzz (16 chars)
the 'hex' code would be &hzz
which doesn't work
so... Clng probably wasn't converting the hex to integer for me for either of those reasons, I'm not sure wether or not I am going to try to emulate what he was doing to the key before setting it as a property
I think he was just basically trying to make the key more complex, but if you mess with the key like that to encrypt it you have to be able to un-mess with it to decrypt and I have way too much stuff to do to try to throw in some extra security on what is already a pretty random 16 byte key and a strong 128 bit encryption.
Phwew