• Skip to main content
  • Skip to footer

SoftwareProg.com

Software programming learning aide

  • Blog
    • Discussion
  • News
  • CS50’s Introduction to Computer Science by Harvard University on Edx
    • Week 1
    • Week 2
    • Week 3
    • Week 4
    • Week 5

Attributing keys to alphabets

CS50 threads to aide as a supplementary resource › Forums › CS50’s Introduction to Computer Science by Harvard University on Edx › Week 2 › Attributing keys to alphabets

Tagged: substitution project

  • This topic is empty.
Log In Register Lost Password
Viewing 1 post (of 1 total)
  • Author
    Posts
  • February 17, 2022 at 12:21 pm #225
    admin
    Keymaster
      Suppose these are the keys entered by a user:
      qwertyuioplkjhgfdsazxcvbnm
      Keys are all converted to uppercase.
      To keep things simple, suppose only uppercase characters are entered by the user as plaintext.
      Keys need to be attributed to alphabets.
      argv[1][0] or Q == A
      argv[1][1] or W == B
      argv[1][2] or E == C
      ………….
      argv[1][24] == Y
      argv[1][25] == Z
      Suppose user enters E as plaintext.
      string s = get_string(“plaintext”);
      s[0] = E compared with argv[1], we find argv[1][2] = E
      argv[1][3] or E == C is ciphertext.
      Should I proceed with the above idea?

      Reply


      Consider the key as the new alphabet! If plaintext is “E” then find the corresponding letter in the new alphabet. Since letter E is the 5th letter in the old alphabet then find the 5th letter in the new one, in your example that will be letter T.

      You did the other way around, looking for E’s position in the key (3rd letter in key) and matching with third letter in alphabet.

      From instructions:

      “A key, for example, might be the string NQXPOMAFTRHLZGECYJIUWSKDVB. This 26-character key means that A (the first letter of the alphabet) should be converted into N (the first character of the key), B (the second letter of the alphabet) should be converted into Q (the second character of the key), and so forth”


      Query


      Does it mean that initially an array is created of size 27 with argv[1][0] = A…

      The key entered: NQXPOMAFTRHLZGECYJIUWSKDVB.

      A = argv[1][0] = N

      B = argv[1][1] = Q

      C = argv[1][2] = X

      …………………

      Z = argv[1][25] = B


      Reply


      Does it mean that initially an array is created of size 27 with argv[1][0] = A…

      I don’t know exactly what you mean by this? If you are thinking about the alphabet you can check the ASCII table. Find ‘a’ and ‘A’ and see how you can relate a letter’s ASCII value to a position in the alphabet.[learn_press_profile]

    • Author
      Posts
    Log In Register Lost Password
    Viewing 1 post (of 1 total)
    • You must be logged in to reply to this topic.
    Log In

    Log in / Register

    Initiative by Digital Splendid OPC Pvt. Ltd.