• [SRC]Rot39

 #100056  por YST
 10 Ago 2009, 19:43
Código: [ Debe registrarse para ver este enlace ]
include 'win32ax.inc'
.data
string db "Hola mundo." ,0
.code
start:
stdcall Len,string
stdcall ROT39,string,eax
mov esi,eax
invoke MessageBox,0,eax,"Encriptado:",0
stdcall Len,esi
stdcall ROT39,esi,eax
invoke MessageBox,0,eax,"Desencriptado:",0
invoke ExitProcess,0
LOWER_LIMIT = 48
CHARMAP  = 39
UPPER_LIMIT  = 125
proc ROT39,pString,pLargo
locals
nCode dd ?
endl
mov eax,[pLargo]
inc eax
invoke GlobalAlloc,GPTR,eax
mov ebx,eax
mov eax,[pLargo]
stdcall cRtlMoveMemory, ebx,[pString],eax
 
dec [pLargo]
xor esi,esi
dec esi
.bucle:
inc esi
mov eax,ebx
add eax,esi
movzx ecx,byte[eax]
mov [nCode] ,ecx
 
.if [nCode] >= LOWER_LIMIT & [nCode] <= UPPER_LIMIT
mov eax,[nCode]
add eax,CHARMAP
mov [nCode],eax
 
.if [nCode] > UPPER_LIMIT
mov eax,[nCode]
sub eax, UPPER_LIMIT
add eax,LOWER_LIMIT
dec eax
mov [nCode] ,eax
.endif
.endif
mov eax,ebx
add eax,esi
mov ecx,[nCode]
mov byte[eax],cl
cmp esi,[pLargo]
jne .bucle
 
mov eax,ebx
ret
endp
proc Len,cCadena ;Funcion que mide la cadena
push ecx edi
mov ecx,-1
mov edi,[cCadena]
mov al,0
repnz scasb
mov eax,ecx
not eax
dec eax
pop edi ecx
ret
endp
;Descripcion: Esta función funciona igual que la winapi RtlMoveMemory
; by YST
proc cRtlMoveMemory,cBuffer,Cpuntero,cCantidad
push esi edi
xchg edi,[cBuffer]
xchg esi,[Cpuntero]
.bucleb:
dec [cCantidad]
movsb
cmp  [cCantidad],0
jge .bucleb
pop edi esi
ret
endp
.end start
 #100067  por masangel
 10 Ago 2009, 20:16
Buen a porte gracias
saludos