cipher text idea ?

Reply

Join Date: May 2009
Posts: 7
Reputation: j_cart007 is an unknown quantity at this point 
Solved Threads: 0
j_cart007 j_cart007 is offline Offline
Newbie Poster

cipher text idea ?

 
0
  #1
May 4th, 2009
this is my code which copies 1st string into 2nd String.

  1. AREA StrCopy1, CODE
  2. SWI_WriteC EQU &2
  3.  
  4. ENTRY ; mark the first instruction
  5. main
  6. ADR r1, srcstr ; pointer to first string
  7. ADR r0, dststr ; pointer to second string
  8. BL strcopy ; copy the first into second
  9. SWI 0x11 ; and exit
  10.  
  11. srcstr DCB " This is my first (source) string",&0a,&0d,0
  12. dststr DCB " This is my second (destination) string",&0a,&0d,0
  13.  
  14. ALIGN ; realign address to word boundary
  15.  
  16. strcopy
  17. LDRB r2, [r1], #1 ; load byte, then update address
  18. STRB r2, [r0], #1 ; store byte, then update address
  19. CMP r2, #0 ; check for zero terminator
  20. BNE printout ; branch if not equal, to Printout
  21.  
  22.  
  23. printOut
  24. SWINE SWI_WriteC ; Print the content
  25. B strcopy ; branch to strcopy
  26. MOV pc, lr ; return
  27. END
*******
Now i want to modify the above code so that it encrypts the dststr using Caesar cipher method and which of course will be printed out on the screen aswell.

Thanks for ur reply and i hope it makes the point clear if not feel free to ask me.

Br.
Last edited by j_cart007; May 4th, 2009 at 3:57 pm.
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 39
Reputation: sysop_fb is an unknown quantity at this point 
Solved Threads: 5
sysop_fb sysop_fb is offline Offline
Light Poster

Re: cipher text idea ?

 
0
  #2
May 5th, 2009
Now i want to modify the above code so that it encrypts the dststr using Caesar cipher method and which of course will be printed out on the screen aswell.

Thanks for ur reply and i hope it makes the point clear if not feel free to ask me.

Br.
A caesar encryption is just a replacement encryption.
Couple of ways to go about this but I only have time to explain two
One is the simpliest you have two strings
ABCDEFGHI
WLPQSRNXZ
You take each char from the source string and find it's equiv in the top string and use that index to find it's equiv in the encryption key there at the bottom.

An faster way would be to setup your encryption key as the previous one for the first 9 characters...
WLPQSRNXZ

Now I find a character in my source string the first character happens to be an 'A' I check a mask to see if it's upper case or lower case and then depending on that outcome I subtract 'A' from it for upper case characters and 'a' from it for lower case characters.
What's this give me? An offset sir 'A' - 'A' is 0 and a 0 offset into our above string is 'W'
'B' - 'A' is 1 so a 1 offset.
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 7
Reputation: j_cart007 is an unknown quantity at this point 
Solved Threads: 0
j_cart007 j_cart007 is offline Offline
Newbie Poster

Re: cipher text idea ?

 
0
  #3
May 5th, 2009
thankx for ur reply sir !
whatever i've got so far is in the code if u can pls have a look and correct me:

  1. AREA text, CODE
  2.  
  3. SWI_WriteC EQU &0
  4.  
  5. ENTRY
  6.  
  7. ADR r4, hello
  8. ADR r3, alpha
  9. ADR r2, key
  10. loop
  11.  
  12. LDRB r0, [r4], #1
  13. CMP r0, #0
  14. BNE check
  15.  
  16. check
  17. LDRB r1, [r3], #1
  18. CMP r0, r1
  19. BEQ encrypt
  20. B loop
  21. encrypt
  22. LDRB r5, [r2], #1
  23. SUB r0,r0,r5
  24. ADD r5,r5,#1
  25. STRB r0,[r5]
  26. SWINE SWI_WriteC
  27. B loop
  28.  
  29. endP
  30.  
  31. MOV pc, lr ; return
  32. END
  33.  
  34. hello DCB "Hello World ",0
  35. alpha DCB "ABCDEFGHIJKLMNOPQRSTUVWXYZ",0
  36. key DCB "XZYCJBTEKMGH",0
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC