guys wondering how come the code doesnt work..
im using tasm as u might know..im checking on things work and want to see what its output be..thanks hope you can help me with this one. i tried converting it tasm but say argument needs to be override.

.model small
.stack 100h
.data
; string has '$' in the end: 
string1 db 'hello world!', 0Dh,0Ah, '$'
;                       'abcdefghijklmnopqrstvuwxyz' 
table1 db 97 dup (' '), 'klmnxyzabcopqrstvuwdefghij'
table2 db 97 dup (' '), 'hijtuvwxyzabcdklmnoprqsefg'
.code
start:
; encrypt: 
lea bx, table1
lea si, string1
call parse
; show result: 
lea dx, string1
; output of a string at ds:dx 
mov ah, 9
int 21h
; decrypt: 
lea bx, table2
lea si, string1
call parse
; show result: 
lea dx, string1
; output of a string at ds:dx 
mov ah, 09
int 21h
ret   ; exit to operating system. 

; subroutine to encrypt/decrypt 
; parameters:  
;             si - address of string to encrypt 
;             bx - table to use. 
parse proc near

next_char:
        cmp [si], '$'
        je end_of_string
	mov al, [si]
	cmp al, 'a'
	jb  skip
	cmp al, 'z'
	ja  skip
	; xlat algorithm: al = ds:[bx + unsigned al]  
	xlatb     ; encrypt using table2.   
	mov [si], al
skip:
	inc si
	jmp next_char
end_of_string:
ret
parse endp
end start

Recommended Answers

All 2 Replies

So only working with lower case in the 'a' to 'z' range for now?

Simple cypher exchange

;cmp [si],'$'
cmp byte ptr [si],'$'

Put the '$' check at the bottom of the loop to save an extra jump each loop!
You can put a pre-jump at the top to jump to the bottom of the loop!

This is a DOS program and you don't exit with a RET

You exit with a
int 20h or ah,4ch int 21h
ret ; exit to operating system.

Using a fixed and not so variable method
to encrypt.
Once broken it is done.

Simple XOR encryption:
XOR encryption is the simplest encryption algorithm
and uses a key (variable in length) for encryption.
key for exampe is 10001011 0x8B
00000101 ^ 10001011 = 10001110 0x8E
10001110 ^ 10001011 = 00000101 0x5
Hence the encryption is the same as the decryption.

XOR val, key ; encrypt
XOR new_val, same_key ; decrypt

XOR encryption is easier and more secure!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.