Question

Decrypting the APCO cipher without the key.

Decryption without the key is obviously a much more difficult process. Indeed, the purpose of encryption is to make it as difficult as possible for anyone who does not know the key to read the plain text. We will be using an unsophisticated password cracking technique called a brute force attack. A brute force attack on the APCO cipher works by trying every possible four digit key (from 0000 to 9999) and keeping the one that gives the best result. How do we know what the “best result” is? The simplest way to test the quality of the decryption key is to count the spaces in the resulting plain text. A space character is the most commonly occurring character in normal text. The key that gives the most spaces in the plain text will almost certainly be the correct key.

Begin by copying the cipher text into your program as asciiz in the data section. (

Lx!ydw!vki!dhwu\"rj!vlqfu/$jv#{bu#xig#{ptvx!qi$ukpit.#mu\"zet\"wlf\"dkf\"rj!ylweqp0!kw$xcv$ujh$bih$ph#jpqomtjqitu/$jv#{bu#xig#iqqfl!qi$cgomfh/$jv#{bu#xig#iqqfl!qi$jpfvffxpjv|0!kw$xcv$ujh$tgdwpp#sg\"omhjw0!kw$xcv$ujh$tgdwpp#sg\"gesmqitu/$jv#{bu#xig#wqtlrh\"rj!jrtf.#mu\"zet\"wlf\"zmovhv!qi$egvtbku0!yh$icg$fxhvzvkmoi#ffhrvf\"xw-\"zi!jdh!prxikqk!dhjpth$vu/$xg#{fth$bno$hqlrh\"gmsgfx!vr$igdzfp/$xg#{fth$bno$hqlrh\"gmsgfx!vki!qwlft#{b{1$Jp#wiqux-\"wlf\"siskrh!ydw!ur$gcu$mkni!vki!ruitgqx!rhvjqg0!vkeu\"vsng#sg\"lxt\"qsjulitv#evvksskwmfu#moulwugg$pp#muu#ffkqk!thgfkyie.#jpt#kpqg$pt#jpt#iwko0!kq$ujh$twsisndxjxh$egjvfg#sg\"fsnrdvjurr!qqpz0

)

Next, write a procedure that counts the number of characters in the cipher text. This information will be useful in the other procedures. Verify this procedure works by testing it on a short string of known length.

Then, write a procedure countSpaces that takes two arguments: the number of characters and the address of the plain text and returns the number of space characters in the given plain text. Verify this procedure works by testing it on a short string with a known number of spaces.

Next, write a procedure decrypt that takes four arguments: the number of characters, the key, the address of the cipher text, and the address of the plain text. This procedure decrypts the cipher text using the given key and writes the result to the plain text.

You can test this procedure on the following short cipher text string: ( to check if its working)

b\"eg!fhj!ikmk\"npnpr$qsuwuw#zxz|~

This cipher text should provide a best key of 1234 and a decrypted text of:

a bc def ghij klmno pqrstu vwxyz (answer)

Place calls to the two above procedures in a loop that steps through all of the possible keys and saves the best one. Once the best key has been found, print it. Run the decrypt function one last time using the best key, then print the resulting plain text.

You can assume that there will never be more than 1000 characters in the cipher text. Note: This program runs very slowly on the long cipher text.

Mips programming ?????

See the following pseudo code:

int numChar = countChar(cipherText)

for (key = 0 to 9999)

decrypt(numChar, key, cipherText, plainText)

int numSpaces = countSpaces(numChar, plainText)

if numSpaces > bestSpaces

bestSpaces = numSpaces

bestKey = key

end for

decrypt(numChar, bestKey, cipherText, plainText)

print bestKey

print plainText

end

Note: the ASCII value for a space is 32. Decrypting the APCO cipher. If the user has the key, then decryption is a simple tas

i was doing it on Mars mips but i am getting lots  of error and the submission date is close i am stuck on how do i use it to decrypt long test and get the best possible key

1. Correctly decrypt the long cipher text and print the key

2. Properly use procedures.

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

Hi Student ,

I will be writing the entire code in Python and let me know if you have any concern , Please repost your query separately

# To get the count of Cipher Text , means total number Of Chars in Cipher Text

def countCipherText(cipherText):

NumberOfCharacterInCipher=0

for e in cipherText:

NumberOfCharacterInCipher+=1  

return NumberOfCharacterInCipher

# To get the count Of Spaces In Plain Text

def countSpaceInPlainText(NumOfCharacterInCipher,AddrOfThePlainText):

return AddrOfThePlainText.count(' ')

  

#To decrypt the string based on the Number Of Character , Based on the Input key And the cipher text

def decryptString(NumOfChar,key,addOfCipherText,addOfPlainText):

result = ''

for l in addOfCipherText:

try:

i = (key.index(l) - NumOfChar) % 26

result += key[i]

except ValueError:

result += l

return result

AddressOfThePlainText='Abcdse nmnmsdnmd salklds slklklds'

cipherText='Lx!ydw!vki!dhwu\"rj!vlqfu/$jv#{bu#xig#{ptvx!qi$ukpit.#mu\"zet\"wlf\"dkf\"rj!ylweqp0!kw$xcv$ujh$bih$ph#jpqomtjqitu/$jv#{bu#xig#iqqfl!qi$cgomfh/$jv#{bu#xig#iqqfl!qi$jpfvffxpjv|0!kw$xcv$ujh$tgdwpp#'

key = 'abcdefghijklmnopqrstuvwxyz'

print "Best Key ",key

print "Decrypted String ",decryptString(countCipherText(cipherText), key, cipherText, AddressOfThePlainText)

Add a comment
Know the answer?
Add Answer to:
Decrypting the APCO cipher without the key. Decryption without the key is obviously a much more...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Implement the RC4 stream cipher in C++. User should be able to enter any key that...

    Implement the RC4 stream cipher in C++. User should be able to enter any key that is 5 bytes to 32 bytes long. Be sure to discard the first 3072 bytes of the pseudo random numbers. THE KEY OR THE INPUT TEXT MUST NOT BE HARD CODED IN THE PROGRAM. program should be tested by a plain text You should write TWO PROGRAMS: encryption and decryption. The encryption program should input the plaintext file and output a cipher text in...

  • C program (Not C++, or C#) Viginere Cipher 1)Ask the user if we are encrypting or...

    C program (Not C++, or C#) Viginere Cipher 1)Ask the user if we are encrypting or decrypting. 2) Ask the user to enter a sentence to be transformed. 3) Ask the user to enter a sentence that will be used as the encryption or decryption key. 4) The sentences (array of characters) should end with a NULL terminator '\0'. 5) The range of values will be all printable characters on the ASCII chart starting with a SPACE - Value 32,...

  • Using C++ Part C: Implement the modified Caesar cipher Objective: The goal of part C is...

    Using C++ Part C: Implement the modified Caesar cipher Objective: The goal of part C is to create a program to encode files and strings using the caesar cipher encoding method. Information about the caesar method can be found at http://www.braingle.com/brainteasers/codes/caesar.php.   Note: the standard caesar cipher uses an offset of 3. We are going to use a user supplied string to calculate an offset. See below for details on how to calculate this offset from this string. First open caesar.cpp...

  • X86 Assembly Language Help to implement the CipherChar Procedure at the end of the given code...

    X86 Assembly Language Help to implement the CipherChar Procedure at the end of the given code INCLUDE Irvine32.inc         .data       KeyPrompt BYTE "Enter the passphrase: ",0       TextPrompt BYTE "Enter the plaintest: ",0           str1 BYTE "The passphrase has length:",0           str2 BYTE "The plaintest has length:",0       KeyIs BYTE "The passphrase: ",0       PlainTextIs BYTE "The plaintext: ",0       CipherTextIs BYTE "The ciphertext: ",0       KMAX = 64                        ; passphrase buffer maximum size       BMAX = 128                       ; test...

  • Develop a Java application that uses a type of encrypted alphabet, called a random monoalphabetic cipher,...

    Develop a Java application that uses a type of encrypted alphabet, called a random monoalphabetic cipher, to encrypt and decrypt a message. Your encryption key and message are to be read in from two different files and then the encrypted message will be output to third file. Then the encrypted message is read in and decrypted to a fourth file. A monoalphabetic cipher starts with an encryption word, removes the redundant letters from the word, and assigns what’s left to...

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