jumps
.model small
.code 
org 100h
start:  mov di,	80h
	cmp byte ptr [di], 0
	je errusg
	mov al, [di]
	mov ah, 0
	mov dx, ax
	dec dx
	mov di, 82h
	mov si,	offset fname1
	mov cx,	0
loop1:	mov al, [di]
	mov [si], al
	inc di
	inc si
	inc cx
	cmp cx, dx
	je errusg
	cmp byte ptr [di], ' '
	je nextloop2
	jmp loop1
nextloop2:
	mov byte ptr [si], 0
loop2:  inc di
	inc cx
 	cmp byte ptr [di], ' '
	je loop2
	mov si,	offset fname2
loop3:  mov al, [di]
	mov [si], al
	inc di
	inc si
	inc cx
	cmp cx, dx
	je begcopy
	cmp byte ptr [di], ' '
	je begcopy
	jmp loop3
begcopy:mov byte ptr [si], 0
	mov ah,	09h
	mov dx, offset inpstr
	int 21h
	mov si,	offset passwd
	mov di,	0
loop4:	mov ah, 08h
	int 21h
	cmp al,	0dh
	je passend
	mov [si], al
	inc si
	inc di
	mov ah,	02h
	mov dl, '*'
	int 21h
	jmp loop4
passend:mov si,	offset passlen
	mov ax, di
	mov byte ptr [si],al
	mov ax, 3d00h
	mov dx,	offset fname1
	int 21h
	jc openerr
	mov si,	ax
        mov ah,	3ch
	mov cx,	0
	mov dx,	offset fname2
	int 21h
	jc openerr
	mov di, ax
;---------------------------------------------
loop8:  mov bx, si
	mov ah, 3fh
	mov dx,	offset buf
	mov cx,	255
	int 21h
	PUSH ax
	PUSH bx
	PUSH dx
	PUSH si
	PUSH di
	mov si, offset passwd
	mov di, offset passlen
	mov dl, [di]
	mov dh, 0
	mov di,	offset buf
	mov cx,	ax
	mov bx, 0

loop5:  mov al, [si]
	xor [di], al
	inc di
	inc si
	inc bx
	mov al, bl
	mov ah, 0
	div dl
	cmp ah, 0 
	je newchange
contin: cmp bx, cx
	je looopend
	jmp loop5
newchange:
	mov si, offset passwd
	jmp contin
looopend:
	POP di
	POP si
	POP dx
	POP bx
	POP ax
	mov ah, 40h
	mov bx, di
	int 21h
	cmp ax, 255
	jb  loopend
        jmp loop8

loopend:mov bx,si
	mov ah,	3eh
	int 21h
        mov bx, di
	mov ah,	3eh
	int 21h
	int 20h
;---------------------------------------
errusg: mov ah,	09h
	mov dx,	offset errstr
	int 21h
	int 20h
openerr:mov ah,	09h
	mov dx,	offset errstr2
	int 21h
	int 20h
errstr  db 'usage: "crypt.exe source dest"$'
errstr2 db 'File not found!$'
inpstr  db 'Enter the password:$'
passwd  db 50 dup (?)
passlen	db ?
fname1	db 13 dup (?)
fname2	db 13 dup (?)
buf	db 256 dup (?)
end start