⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 enc.txt

📁 文件加密程序,汇编语言编写程序,源代码基本代码
💻 TXT
字号:
data segment
seed        db ?
handle        dw ?
bufferSize    db 13
nameLen        db ?
fileName    db 14 dup(0)
tips        db ''Please input the name of the encode/decode file!'',0ah,0dh,''$''
seedMSG        db ''Please input the number for encode/decode(such as 123)(<=255)'',0ah,0dh,''$''
errorMSG    db ''error'',''$''
buf        db 256 dup(?)
len        dw ?
fileLen        dw 0
data ends

code segment
assume cs:code,ds:data
chooseFile proc
start:    mov ax,data
    mov ds,ax
    
    mov ah,09h
    lea dx,tips
    int 21h

    mov ah,0ah
    lea dx,bufferSize
    int 21h
    mov bh,0
    mov bl,nameLen
    mov fileName[bx],0

    lea dx,fileName
    mov ax,3d02h    ;AL=0为读文件,AH=3DH是功能号
    int 21h
    jc  error    ;若打开出错,转到去打开默认文件
    mov Handle,ax
            ;输入加密种子
    mov ah,09h
    lea dx,seedMSG
    int 21h
    mov ah,0ah
    lea dx,bufferSize
    int 21h
    cmp nameLen,4
    jnb error    ;大于四则为错误输入
    mov bh,0
    mov bl,nameLen
    mov fileName[bx],0
    mov fileName[bx+1],10
    mov fileName[bx+2],20
    lea di,fileName

    sub [di],30h
    mov ah,100
    mov al,[di]
    mul ah
    mov bx,ax
    sub [di],30h
    mov ah,10
    mov al,[di+1]
    mul ah
    add bx,ax
    add al,[di+2]
    sub al,30h
    mov seed,al
    
read:    mov bx,Handle
    lea dx,buf
    mov cx,255    ;指定读文件字节数
    mov ah,3fh
    int 21h
    jc  error
    cmp ax,0
    jz  over
    mov len,ax    ;ax=实际读到的字符数

    mov cx,len    ;加密
    lea di,buf
    mov al,seed
encode:    xor [di],al
    inc di
    loop encode
            ;CX=0,移动文件指针
    mov dx,fileLen
    mov ax,4200h
    int 21h
    mov cx,len    ;加密后写入文件
    mov bx,handle
    lea dx,buf
    mov ah,40h
    int 21h
    jc error
    mov ax,len
    add fileLen,ax
    jmp read
error:
    lea dx,errorMSG
    mov ah,09h
    int 21h
over:    mov ah,4ch
    int 21h
chooseFile endp
code ends
end start

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -