AI, Data Science, & Programming for Small Business Applications & Large Enterprises › Forums › CS50’s Introduction to Computer Science by Harvard University on Edx › Week 2: [Arrays] – Functions, Variable and Scope, Debugging, Arrays, and Command Line Arguments › Attributing keys to alphabets
Tagged: substitution project
- This topic is empty.
-
AuthorPosts
-
February 17, 2022 at 12:21 pm #225Suppose these are the keys entered by a user:qwertyuioplkjhgfdsazxcvbnmKeys 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 == Aargv[1][1] or W == Bargv[1][2] or E == C………….argv[1][24] == Yargv[1][25] == ZSuppose user enters E as plaintext.string s = get_string(“plaintext”);s[0] = E compared with argv[1][i ], we find argv[1][2] = Eargv[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]
-
AuthorPosts
- You must be logged in to reply to this topic.