; Author: Jake Commander
; Copyright The GeneSys Development System
HexEncode proc uses edi esi ebx pBuff:dword,dwLen:dword,pOutBuff:dword
;---------------------------------------
mov ebx, dwLen
mov edi, pOutBuff
test ebx, ebx
mov esi, pBuff
jz @F
.repeat
movzx eax, byte ptr [esi]
mov ecx, eax
add edi, 2
shr ecx, 4
and eax, 1111b
and ecx, 1111b
cmp eax, 10
sbb edx, edx
adc eax, 0
lea eax, [eax+edx*8+'7']
cmp ecx, 10
sbb edx, edx
adc ecx, 0
shl eax, 8
lea ecx, [ecx+edx*8+'7']
or eax, ecx
inc esi
mov [edi-2], ax
dec ebx
.until ZERO?
@@: mov eax, edi
mov byte ptr [edi], 0
sub eax, pOutBuff
ret
;---------------------------------------
HexEncode endp
; Author: Jake Commander
; Copyright The GeneSys Development System
HexDecode proc uses esi edi ebx pHexStr:dword,pOutBuffer:dword
;---------------------------------------
mov esi, pHexStr
mov edi, pOutBuffer
jmp @1
@@: and ebx, 0Fh
add eax, ebx
mov [edi], al
inc edi
@1: movzx edx, byte ptr[esi]
cmp edx, 40h
sbb ebx, ebx
sub edx, 37h
and ebx, 7
inc esi
add ebx, edx
js @F
mov eax, ebx
shl eax, 4
mov [edi], al
movzx edx, byte ptr [esi]
cmp edx, 40h
sbb ebx, ebx
sub edx, 37h
and ebx, 7
inc esi
add ebx, edx
jns @B
@@: ret
;---------------------------------------
HexDecode endp
Link:http://www.winasm.net/forum/index.php?showtopic=2618