大学时期vs2003写的汇编加密解密:
.386
.model flat ,stdcall
option casemap :none
includelib msvcrt.lib
fopen proto c :dword ,:dword
fread proto c :dword ,:dword ,:dword ,:dword
fwrite proto c :dword ,:dword ,:dword ,:dword
fseek proto c :dword ,:dword ,:dword
fclose proto c :dword
feof proto c :dword, :dword
scanf proto c szformat :dword ,:vararg
printf proto c szformat :dword ,:vararg
.data
;输出格式
szinputs byte "%s%s%s",0
;提示
szinput byte "欢迎您使用FKZXF-加密工具",0ah,0
szinputs1 byte "错误:文件路径不存在或被其它程序使用",0ah,0
szinputs2 byte "错误:加密或解密参数不正确",0ah,0
szinputs3 byte "格式1:参数1 参数2 参数3",0ah,"格式2:参数1(回车)参数2(回车)参数3(回车)",0ah,0
szinputs9 byte "工作完成!",0ah,0
szinputs0 byte "请输入以下3个参数",0ah,"(1) 文件完整路径",0ah,"(2) +/- +:代表加密,-:代表解密",0ah,"(3) 密码(最大支持128位密码)",0ah,0
;重要
model byte "r+b",0
filename byte 80 dup(0); 文件名
op byte ?; +=加密 -=解密
password byte 128 dup(0) ;参数
fp dword ?;FILE*fP;
buf byte 128 dup(0);缓冲区
bytes dword ?;读入字节数
position dword 0; 写入位置
n byte 0
.code
start:
invoke printf,offset szinput
A:
invoke printf,offset szinputs0
invoke printf,offset szinputs3
invoke scanf ,offset szinputs,offset filename,offset op,offset password
invoke fopen,offset filename,offset model
mov fp,eax
cmp fp,0
jz END0
cmp op,'+'
jz B0
cmp op,'-'
jz B0
jmp END1
B0:
invoke fseek, fp,position,0
invoke fread,offset buf ,1,size buf ,fp
cmp eax ,0
jz END3 ;读完文件,则工作完成
mov bytes ,eax
mov ecx ,eax
mov ebx,0
B1:
mov al,buf[ebx]
cmp op,"+"
jz B2
sub al ,byte ptr password[ebx]
jmp B3
B2:
add al,byte ptr password[ebx]
B3:
mov buf[ebx],al
inc ebx
loop B1
invoke fseek, fp,position,0
invoke fwrite,offset buf ,1,bytes,fp
cmp eax,0
jz END3
mov ebx,bytes
add position,ebx
jmp B0
jmp END3
END0:
invoke printf,offset szinputs1
jmp A
END1:
invoke printf,offset szinputs2
jmp A
END3:
invoke printf,offset szinputs9
ret
end start