;Crypto API,For hashing,encrypting and decrypting,work on winXP xp3
;Author:ZYR零零发,
;Date:02/09/2010
;hashing:MD5
;Encrypting/Decrypting(STREAM CIPHER): RC4
;Use masm ver10.0
;For guidance from msdn and Tyg-'s work
.386
.model flat,stdcall
option casemap:none
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
include windows.inc
include user32.inc
include kernel32.inc
include advapi32.inc
include gdi32.inc
includelib user32.lib
includelib kernel32.lib
includelib advapi32.lib
includelib gdi32.lib
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;等值定义
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
PKCS_7_ASN_ENCODING equ 00010000h
X509_ASN_ENCODING equ 00000001h
ALG_SID_MD5 equ 00000003h
ALG_SID_RC4 equ 00000001h ;stream cipher
ALG_SID_RC2 equ 00000002h ;block cipher
CALG_MD5 equ ALG_CLASS_HASH OR ALG_TYPE_ANY OR ALG_SID_MD5
CALG_RC4 equ ALG_CLASS_DATA_ENCRYPT OR ALG_TYPE_STREAM OR ALG_SID_RC4
CALG_RC2 equ ALG_CLASS_DATA_ENCRYPT OR ALG_TYPE_BLOCK OR ALG_SID_RC2
IDC_EDIT1 equ 1001
ID_HASH equ 2001
IDC_EDIT2 equ 1002
ID_ENCRYP equ 2002
IDC_EDIT3 equ 1003
ID_DECRYP equ 2003
ICO_MAIN equ 1
DLG_MAIN equ 2
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.const
szNo1 db 'hProv create unsuccessful!',0
szNo2 db 'hHash create unsuccessful!',0
szNo3 db 'hashdata unsuccessful!',0
szNo4 db 'gethash failed!',0
szNo5 db 'createkey failed!',0
szNo6 db 'encrypt failed!',0
szNo7 db 'decrypt failed!',0
.code
;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
;It is convert BYTE to string
;_lenght,length of buffer that contain byte
; _lpbit,buffer that contain byte
;_lpstr,Accepted string converted from _lpbit,It must allocate memory enough
;the process written by a guy named Tyg-,I thanks very much.
;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
_Btos proc _lenght,_lpbit,_lphexstr
pushad
mov ecx,_lenght
mov esi,_lpbit
mov edi,_lphexstr
@@:
mov al,byte ptr[esi]
and al,0F0h
shr al,4
.if al<=9
add al,"0"
mov byte ptr[edi],al
.else
sub al,10
add al,"A"
mov byte ptr[edi],al
.endif
inc edi
mov al,byte ptr[esi]
and al,0Fh
.if al<=9
add al,"0"
mov byte ptr[edi],al
.else
sub al,10
add al,"A"
mov byte ptr[edi],al
.endif
inc edi
inc esi
dec ecx
cmp ecx,0
jnz @B
mov byte ptr[edi],0
xor eax,eax
popad
ret
_Btos endp
_ProcDlgMain proc uses ebx edi esi hWnd,wMsg,wParam,lParam
local @szBuffer[128]:byte
local @szBuffer1[256]:byte
local @dwBufferSize,@dwPwdsize
mov @dwBufferSize,sizeof szBuffer
mov eax,wMsg
.if eax == WM_CLOSE
invoke EndDialog,hWnd,NULL
.elseif eax == WM_INITDIALOG
invoke LoadIcon,hInstance,ICO_MAIN
invoke SendMessage,hWnd,WM_SETICON,ICON_BIG,eax
invoke GetDlgItem,hWnd,ID_ENCRYP
invoke EnableWindow,eax,FALSE
.elseif eax == WM_COMMAND
mov eax,wParam
.if ax == ID_HASH