▾ Part 5: SBUncryption (10 points) [NEW PROBLEM] For this part you will complete the function encrypt, which implements

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
correctanswer
Posts: 43759
Joined: Sat Aug 07, 2021 7:38 am

▾ Part 5: SBUncryption (10 points) [NEW PROBLEM] For this part you will complete the function encrypt, which implements

Post by correctanswer »

Part 5 Sbuncryption 10 Points New Problem For This Part You Will Complete The Function Encrypt Which Implements 1
Part 5 Sbuncryption 10 Points New Problem For This Part You Will Complete The Function Encrypt Which Implements 1 (98.65 KiB) Viewed 70 times
▾ Part 5: SBUncryption (10 points) [NEW PROBLEM] For this part you will complete the function encrypt, which implements a fictional data encryption algorithm called SBUncryption. The function takes three arguments (plaintext, chunk_size, extras), which are explained below. First, imagine that we divide the input, called plaintext, into chunks of chunk_size characters. For instance, if chunk_size = 3, this means we take groups (chunks) of 3 characters at a time. Second, imagine we concatenate all the chunks back together, but reversing every other one (starting with the second chunk). (The leftmost chunk is the "first" one, not the "zeroth" one.) Finally, and just before we concatenate the chunks together in the second step, we salt the password by adding some extraneous characters to frustrate decryption. More specifically, draw a single character at a time from the extras argument, adding that character at the end of a chunk in the plaintext. Draw characters until you run out of characters or we reach the last chunk, whichever comes first. For instance, if extras has 5 characters, but there are 8 chunks, only the first 5 chunks will get an extra character. Worked-out example: Assume plaintext = 'United States of America', chunk_size = 5, extras = 'FLAG' 1. Divide into chunks: Unite, d Sta, tes o, f Ame, rica 2. Reverse every other chunk: Unite, atS d, tes o, emå f, rica 3. a. Add salt characters to as many chunks as possible: UniteF, ats dL, tes oA, emA fG, rica. Note that the only the first four chunks got an extra letter at the end (F, L, A, G). b. Concatenate everything together: UniteFatS dLtes oAemA fGrica Examples: Function Call Return Value abc8fedAghiLkjT StonrB yook vinUersiyt UniteFats dLtes oAemA férica encrypt (abcdefghijk', 3, 'SALTY') encrypt (Stony Brook University', 4, **). encrypt (United States of America', 5, 'FLAG') encrypt (United States of America', 3, 'FLAG') encrypt (Declaration of Independence, 6, America') encrypt (Declaration of Independence', 5, 'USA') UniFdetL StAetaGs of fmeraci DeclarA noitamof Indeedneperncei DeclaUoitarSn of ApednIendenec
Register for solutions, replies, and use board search function. Answer Happy Forum is an archive of questions covering all technical subjects across the Internet.
Post Reply