Oh!, sorry, but i have problems accessing forums:
http://forums.purebasic.com/ 
So i was no able to reply until now.
blueznl wrote:never could resist a challenge
(and i think this is slightly more readable and perhaps a little faster?)
I like that
Froggerprogger wrote:Err. Yes, I just read 'Hex2Dec' and started my posting, sorry...
@Psychophanta
Nice! And the other way round ?
ValByteSequenceToHexByteString () ?

Yes, i made it (of course, keep in mind that sequences are treated a big endian, this is raw; from left to right

Here is the complete thing:
Code: Select all
;This function converts a given Hex string (.s) to a byte sequence stored in a given base address of sequential memory:
Procedure.b HexByteStringToDecByteSequence(HexString.s,*mem.Byte)
Nibbles.l=Len(HexString.s)
If Nibbles.l&1:HexString.s="0"+HexString.s:Nibbles.l+1:EndIf
For t.l=1 To Nibbles.l
c.w=Asc(Mid(HexString.s,t.l,1))
If c.w<'0' Or (c.w>'9' And c.w<'A') Or (c.w>'F' And c.w<'a') Or c.w>'f'
ProcedureReturn 0
EndIf
If c.w>'9':c.w=(c.w&$5F)-$07:EndIf
c.w-'0'
If t.l&1
*mem\b=c.w<<4
Else
*mem\b|c.w
*mem+1
EndIf
Next
ProcedureReturn 1
EndProcedure
;Test it:
*d.b=AllocateMemory(22)
HexByteStringToDecByteSequence("7e5d772777c7884ab7ebebcd8fabada",*d.b)
For t=1 To 22
Debug Hex(PeekB(*d.b+t-1)&$FF)
Next
;********************************************************************************************
;This function converts a byte sequence stored in a given base address of sequential memory to a Hex string (.s):
Procedure DecByteSequenceToHexByteString(*seq.Byte,length.l,*HexString.Byte)
For t.l=1 To length.l
*HexString\b=Asc(Hex((*seq\b>>4)&$0F)); <-HighNibble
*HexString+1
*HexString\b=Asc(Hex(*seq\b&$0F)); <-LowNibble
*HexString+1
*seq+1
Next
*HexString\b=0
EndProcedure
;Test it:
st.s=Space(22*2)
DecByteSequenceToHexByteString(*d.b,22,@st.s)
Debug st.s