Question

MASM Assembly language -- Message Encryption Pgm You are to write a program to input a...

MASM Assembly language -- Message Encryption Pgm

You are to write a program to input a text and a key and encrypt the text. I will supply you an encryption key consisting of multiple characters. Use this key to encrypt and decrypt the plain text by XOR-ing each character of the key against a corresponding byte in the message. Repeat the key as many times as necessary until all plain text bytes are translated. Suppose, for example, the key were equal to "ABXmv#7", you would then repeat the key down the text until the entire text was encrypted. This is how the key would align with the plain text bytes:


Plain Text: T h i s   i s   a   P l a i n t e x t   m e s s a g e .
Key:        A B X m v # 7 A B X m v # 7 A B X m v # 7 A B X m v # 7

Input file will be a Text line (one line) next input is the key. The file will have several sets of inputs.

Example   Line One text
   abcKEY
   The second line of text
   KEYzyz133*$
   ...

Output:       print out line of original text,
   the encrypted text
   the decrypted text.
   A space line or two
   next lines...

Input file:

This is the first line of text to encrypt so have at it and have fun.
AV)$'932jk
My name is Secret Agent and I'm a counter spy for a large organization, the Itty Bitty Tinny Space ship to Mars program.
(9^54~JHT<>"]}aqd
The quarterly report in-house and confidential is being released on April 15 after the sun flair passes, Venus and mars are snuggle buddies and Haley’s comet passed Jupiter.
KiKjva*)(82199{}|x
The 2017 thru 2022 future accounting target is $204,000,000 in cost projections, with #100,500,000 in expenses showing $103,500,000 profit. I think this will be good for us and bad for them.
KHJ99*&$-";lkj:B:1](t&
I wish to conclude that this message will self destruct in 20 seconds and will have an impact for the next 25 years, 157 days, 16.5 hours, 23 minutes and then start over. Keep this under raps.
8&45$:Aa~

1 0
Add a comment Improve this question Transcribed image text
✔ Recommended Answer
Answer #1

INCLUDE Irvine32.inc

KEY = 239           ; any value between 1-255

BUFMAX = 128        ; maximum buffer size

.data

sPrompt BYTE "Enter the plain text: ",0

sEncrypt BYTE "Cipher text:          ",0

sDecrypt BYTE "Decrypted:            ",0

buffer   BYTE   BUFMAX+1 DUP(0)

bufSize DWORD ?

.code

main PROC

    call    InputTheString      ; input the plain text

    call    TranslateBuffer ; encrypt the buffer

    mov edx,OFFSET sEncrypt ; display encrypted message

    call    DisplayMessage

    call    TranslateBuffer     ; decrypt the buffer

    mov edx,OFFSET sDecrypt ; display decrypted message

    call    DisplayMessage

    exit

main ENDP

    pushad

    mov edx,OFFSET sPrompt ; display a prompt

    call    WriteString

    mov ecx,BUFMAX      ; maximum character count

    mov edx,OFFSET buffer   ; point to the buffer

    call    ReadString          ; input the string

    mov bufSize,eax         ; save the length

    call    Crlf

    popad

    ret

InputTheString ENDP

    pushad

    call    WriteString

    mov edx,OFFSET buffer   ; display the buffer

    call    WriteString

    call    Crlf

    call    Crlf

    popad

    ret

DisplayMessage ENDP

    pushad

    mov ecx,bufSize     ; loop counter

    mov esi,0           ; index 0 in buffer

L1:

    xor buffer[esi],KEY ; translate a byte

    inc esi             ; point to next byte

    loop    L1

    popad

    ret

TranslateBuffer ENDP

END main

Add a comment
Know the answer?
Add Answer to:
MASM Assembly language -- Message Encryption Pgm You are to write a program to input a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
  • In this lab, you will write a C program to encrypt a file. The program prompts...

    In this lab, you will write a C program to encrypt a file. The program prompts the user to enter a key (maximum of 5 bytes), then the program uses the key to encrypt the file. Note that the user might enter more than 5 characters, but only the first 5 are used. If a new line before the five characters, the key is padded with 'a'; Note that the new line is not a part of the key, but...

  • C Programming - RSA Encryption I've tried to write a program that can encrypt and decrypt...

    C Programming - RSA Encryption I've tried to write a program that can encrypt and decrypt strings using RSA and want to be able to integrate it into a header file which contains codes for compression, linked list etc.. However, the use of global variables and fixed size of encryption is making it hard to do so Can someone please help me modify the following the code? I want to be able to just pass it in a string to...

  • C Programming - RSA Encryption I've tried to write a program that can encrypt and decrypt strings using RSA and want...

    C Programming - RSA Encryption I've tried to write a program that can encrypt and decrypt strings using RSA and want to be able to integrate it into a header file which contains codes for compression, linked list etc.. However, the use of global variables and fixed size of encryption is making it hard to do so Can someone please help me modify the following the code? I want to be able to just pass it in a string to...

  • 4. Suppose you wish to encrypt the message, M 42 using RSA encryption. Given a public...

    4. Suppose you wish to encrypt the message, M 42 using RSA encryption. Given a public key where p- 23 and q-11 and the relative prime e- 7. Find n, and show all necessary steps to encrypt your message (42). (Hint: check p.411 of the text for information on public key RSA) (5 points)

  • Implement in Go language AES encryption mode CBC with providing the packages name for Go language....

    Implement in Go language AES encryption mode CBC with providing the packages name for Go language. You can implement AES-ECB Mode (the basic AES) from crypto/aes package and crypto/cipher.Block. You can also get the SHA-256 hash function from crypto/sha256. You can get the secure random numbers generator from crypto/rand package. However, the you will implement both CBC mode and HMAC from scratch. You are NOT allowed to use any libraries or packages to implement these two things for you. You...

  • 1.     This project will extend Project 3 and move the encryption of a password to a...

    1.     This project will extend Project 3 and move the encryption of a password to a user designed class. The program will contain two files one called Encryption.java and the second called EncrytionTester.java. 2.     Generally for security reasons only the encrypted password is stored. This program will mimic that behavior as the clear text password will never be stored only the encrypted password. 3.     The Encryption class: (Additionally See UML Class Diagram) a.     Instance Variables                                                i.     Key – Integer...

  • I need Help to Write a function in C that will Decrypt at least one word with a substitution cipher given cipher text an...

    I need Help to Write a function in C that will Decrypt at least one word with a substitution cipher given cipher text and key My Current Code is: void SubDecrypt(char *message, char *encryptKey) { int iteration; int iteration_Num_Two = 0; int letter; printf("Enter Encryption Key: \n");                                                           //Display the message to enter encryption key scanf("%s", encryptKey);                                                                   //Input the Encryption key for (iteration = 0; message[iteration] != '0'; iteration++)                               //loop will continue till message reaches to end { letter = message[iteration];                                                      ...

  • C Program In this assignment you'll write a program that encrypts the alphabetic letters in a...

    C Program In this assignment you'll write a program that encrypts the alphabetic letters in a file using the Vigenère cipher. Your program will take two command line parameters containing the names of the file storing the encryption key and the file to be encrypted. The program must generate output to the console (terminal) screen as specified below. Command Line Parameters Your program must compile and run from the command line. The program executable must be named “vigenere” (all lower...

  • In Python, do a basic encryption of a text file in the following manner. The program...

    In Python, do a basic encryption of a text file in the following manner. The program encrypt.py will read in the following text file and rearrange the lines in the file randomly and save the rearranged lines of txt to another file called encrypted.txt. It will also save another file called key.txt that will contain the index of the lines that were rearranged in the encrypted file, so for example if the 4th line from the original file is now...

  • 1. In this lab, you will create a simple encryption function that will require a sentence...

    1. In this lab, you will create a simple encryption function that will require a sentence and a key (both strings) as a parameter and return an encrypted version of the string. The encryption algorithm will use the exclusive OR operator (commonly abbreviated as XOR). The general structure of the encryption is that every position in the sentence is XOR'd with the accompanying position of the key. If the sentence is longer than the key, you repeat the key. For...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT