Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write an ARM function that will attempt to decrypt a string encrypted using the

ID: 3694519 • Letter: W

Question

Write an ARM function that will attempt to decrypt a string encrypted using the Caesar cipher.

Supposedly Caesar used this technique to encrypt messages. He moved from the letter of the text to the third letter up in the alphabet and used that letter in the message. For example to encode the letter C he moved up three positions and used the letter F in the message. When at the end of the alphabet he wrapped around to the beginning, e.g. the letter Z was encrypted as C.

/* decrypt the string encrypted via Caesar shift */

#include <stdio.h>

extern void init( char * encrypt ) ;

extern char * decrypt( char * encypt, int shift ) ;

void main( int argc, char * argv[] )

{

   char * result ;                         /* pointer to decrypted string */

   char encrypt[] = "GSRKVEXYPEXMSRW CSY LEZI JSYRH XLI WLMJX ZEPYI" ;

            int i ;

            init( encrypt ) ;

            for( i = 1 ; i < 5 ; i++ )               /* loop to try various shifts */

            {

                        result = decrypt( encrypt, i ) ;

                        printf( "Possible decrypt with shift %d: %s ", i, result ) ;

            }

}

There are two functions that need to be written. They must both be in the same source file since the first obtains a buffer for the decrypted string and the second uses the buffer to hold the guess.

Explanation / Answer

Here is my ARM code (this is all in one file called decrypt.s):

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote