please could you help me i have a file :
Listing 1
.model small
.stack 100h
.data
buffer db 100 dup(0)
entry db "Welcome to simple edit program",0ah,0ah,'$'
enter db "Please enter character - ESC to leave",0ah,0dh,'$'
endit db "Terminate the program",0ah,0dh,'$'
.code
; A marco for printing messages..
mdisplay macro string
push ax ;push ax onto the stack
push dx ;same for dx
mov ah,9 ;service 9 (drint a string).
mov dx,offset string ;the string to print
int 21h ;do it!
pop dx ;pop dx off stack
pop ax ;pop ax off stack
endm
; to end the marco..
main proc near
mov ax,@data
mov ds,ax
mdisplay entry
;-----------------------------------------
mov bx,offset buffer
mdisplay enter
.repeat
call readkey ;read a key value
call dispch ;echo to screen
mov byte ptr[bx],al ;store in buffer
inc bx ; increment buffer pointer
.until (bx == offset buffer+100 || [bx-1]==1bh)
mdisplay endit
;----------------------------------------
mov ax,4c00h
int 21h
;ret
main endp
;------------------------
readkey proc near
mov ah,0
int 16h
ret
readkey endp
;------------------------
dispch proc near
push bx
mov bx,0
mov ah,14
int 10h
pop bx
ret
dispch endp
end
I need to modify the above program in order to encrypt text entered using a key someting like the following:
.model small
.stack 100h
XORVAL = 111 ;could be any value between 0-255
.code
main proc near
mov ax,@data
mov ds,ax ;don't really need access to data segment.
L1:
mov ah,6 ;direct console input
mov dl,0ffh ;don't wait for character (coming from a file).
int 21h ;will return character in AL.
jz L2 ;quit reading if zero (ZF=1) since EOF.
xor al,XORVAL ;encrypt the data with our key.
mov ah,2 ;write data to output.
mov dl,al ;wants to see data in dl.
int 21h ;do it!
jmp L1 ;if it gets to here jump back to L1 and repeat.
L2:
mov ax,4c00h ;get ready to quit program and return to DOS.
int 21h ;teminate the program here.
main endp
end
but this only encrypts from a file if you enter at the dos prompt "test < plain > coded" using the aside program
any ideas?
Listing 1
.model small
.stack 100h
.data
buffer db 100 dup(0)
entry db "Welcome to simple edit program",0ah,0ah,'$'
enter db "Please enter character - ESC to leave",0ah,0dh,'$'
endit db "Terminate the program",0ah,0dh,'$'
.code
; A marco for printing messages..
mdisplay macro string
push ax ;push ax onto the stack
push dx ;same for dx
mov ah,9 ;service 9 (drint a string).
mov dx,offset string ;the string to print
int 21h ;do it!
pop dx ;pop dx off stack
pop ax ;pop ax off stack
endm
; to end the marco..
main proc near
mov ax,@data
mov ds,ax
mdisplay entry
;-----------------------------------------
mov bx,offset buffer
mdisplay enter
.repeat
call readkey ;read a key value
call dispch ;echo to screen
mov byte ptr[bx],al ;store in buffer
inc bx ; increment buffer pointer
.until (bx == offset buffer+100 || [bx-1]==1bh)
mdisplay endit
;----------------------------------------
mov ax,4c00h
int 21h
;ret
main endp
;------------------------
readkey proc near
mov ah,0
int 16h
ret
readkey endp
;------------------------
dispch proc near
push bx
mov bx,0
mov ah,14
int 10h
pop bx
ret
dispch endp
end
I need to modify the above program in order to encrypt text entered using a key someting like the following:
.model small
.stack 100h
XORVAL = 111 ;could be any value between 0-255
.code
main proc near
mov ax,@data
mov ds,ax ;don't really need access to data segment.
L1:
mov ah,6 ;direct console input
mov dl,0ffh ;don't wait for character (coming from a file).
int 21h ;will return character in AL.
jz L2 ;quit reading if zero (ZF=1) since EOF.
xor al,XORVAL ;encrypt the data with our key.
mov ah,2 ;write data to output.
mov dl,al ;wants to see data in dl.
int 21h ;do it!
jmp L1 ;if it gets to here jump back to L1 and repeat.
L2:
mov ax,4c00h ;get ready to quit program and return to DOS.
int 21h ;teminate the program here.
main endp
end
but this only encrypts from a file if you enter at the dos prompt "test < plain > coded" using the aside program
any ideas?