CP5639 | Assignment 2 | IT

Home Recent Questions CP5639 | Assignment 2 | IT

You are to implement the Magic cube encryption program which you planned for in the first assignment, keeping in mind there are changes in the way the program should run. Use what you have learned in class, including functions, lists, selections and repetitions in Python. You should use any feedback that you received from Assignment 1 to improve your program flow.

So far in the first assignment you have learned to encrypt an 8-character string using the magic cube.
If the string is longer than 8 characters, then multiple cubes can be used, each cube storing 8 characters, and each cube going through the same rotation. If the string’s length is not a multiple of 8, then empty spaces should be added at the end.

Consider for example the string “Hello world!” with a length of 12 characters, including the space and the exclamation mark. Let’s encrypt this string with two rotations, one to the right, the second upwards. First, we add spaces to make the string’s length a multiple of 8, so we add 4 extra spaces at the end. Then, we separate the characters into blocks of 8 and assign a cube to each block:
Hello world!

cube 1: Hello wo
cube 2: rld!

We obtain 2 cubes: the first one with the characters “Hello wo”, the second with the characters “rld!____”. Each string is “placed” on its cube; if we rotate these two cubes rightwards, “Hello wo” becomes “e wlHool” and “rld!____” becomes “l dr !”. Joined together, these make “e wlHool l dr !”, which of course is not intelligible.

1.cube 1: Hello wo     rightwards      e wlHool
  cube 2: rld!                                          l dr !

Let’s rotate this result upwards! The first cube leads to “lwole oH”, while the second cube leads to "d !l r"; combined they make “lwole oH d !l r”.

2.cube 1: e wlHool     upwards         lwole oH
  cube 2: l dr !                                      d !l r

So the initial string “Hello world!____” rotated rightwards (R), then upwards(U) became “lwole oH d !l r”. Namely, it has been encrypted.

How could we decrypt it, or how could we convert it back to the intelligible format? How to get from “lwole oH d !l r” back to “Hello world!”? We should apply the RU formula backwards and reverse the rotations! The reverse of rotating leftwards is rotating rightwards, the reverse of rotating upwards is downwards and so on.

RU read backwards is UR, and UR reversed is DL (downwards and leftwards). So to decrypt the string we must rotate the unintelligible final message downwards then leftwards! Let’s try it!

The first cube contained “lwole oH”, while the second cube "d !l r"; rotated downwards, the first becomes “e wlHool” and the second becomes” l dr !”. Further, if we rotate these two leftwards we obtain “Hello wo” and respectively “rld!____”; joined together these make our initial string, from which we can ignore the spaces at the end.

1.cube 1: lwole oH     downwards      e wlHool
cube 2: d !l r                                            l dr !

2.cube 1: e wlHool     leftwards      Hello wo
cube 2: l dr !                                      rld!

Search Here

Latest Reviews

  • Marcus
    30 Apr, 2019

    My assignment help services are provided in the best way by this website. The writers have completed my assignment in such a way that they helped me increase my overall performance.

  • Emy
    29 Apr, 2019

    Awesome work done by the experts of this company. I visited this site to get math assignment completed. My assignment was complete in every aspect. Thanks to the professionals who provided assignment writing help.

  • Darina
    25 Apr, 2019

    All thanks to the writers of Assignment Help 4 Me who completed my Physics assignment in the right manner. The structure of the assignment was totally customized according to my needs and that too at cheap prices.

View All Reviews


Assignment Help 4 Me