Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

Question

Create a program that will encrypt letters and create a secret code. You will

create an array of numbers from 0 - 25.

use [i for i in range (26)] to create an array of numbers from 0 - 25.

use random.shuffle to to shuffle the above array. This will be used for a new letter index order.

For example:

The first created array

[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]

gets shuffled to become
[2, 14, 12, 20, 16, 5, 11, 1, 13, 17, 15, 21, 19, 10, 23, 22, 25, 3, 6, 7, 18, 4, 9, 24, 0, 8]

This will be used as the new index for the encrypted alphabet.

create an array of letters using list(string.ascii_lowercase), this requires importing the string module.

This will create:

['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']

Accept an input of a word. Using the above tables take each letter of the word and convert it to the encrypted letter.

Print each letter with the existing letter value and the encrypted letter value.

Print the newly encrypted word.

Sample output:

>>>

enter string to encrypt: congratulations
c 2 11
o 14 9
n 13 5
g 6 24
r 17 7
a 0 15
t 19 17
u 20 1
l 11 23
a 0 15
t 19 17
i 8 0
o 14 9
n 13 5
s 18 16
ljfyhprbxprajfq
>>>

Extra credit include a space as an encrypted character and allow for multiple words.

Flowchart:

[画像:The flowchart titled "Secret Code" outlines a process for creating and printing an encrypted word using random sampling and string manipulation. Here’s a detailed explanation of each step: 1. **Start**: - The process begins with the "Secret Code" initiation. 2. **Import Libraries**: - Import the `random` and `string` modules, which are essential for randomization and handling string data. 3. **Create Array for Index**: - Initialize an array to hold index values that will be used for encryption. 4. **Assign Random Sample to Array**: - Populate the index array with a random sample to generate a key for encryption. 5. **Create Array for Alphabet**: - Create an array consisting of the alphabet, which will be referenced to assign letters during encryption. 6. **Decision: End of Word**: - A decision point checks whether the end of the word has been reached. - **If Yes**: - Proceed to print the encrypted word. - **If No**: - Continue with the following steps. 7. **Assign Letter Index**: - Determine the index of the current letter for processing. 8. **Print Letter Information**: - Output the current letter, its old index, and the new index for tracking purposes. 9. **Concatenate New Encrypted String**: - Append the modified letter to form the new encrypted string. 10. **Repeat Process**: - Loop back to the decision point to process the next letter until the entire word is encrypted. 11. **End**: - The process concludes with the encrypted word being printed out. This flowchart effectively demonstrates a simple method for encrypting a word by reassigning letters based on randomized indices, showcasing basic encryption logic utilizing Python libraries.]
expand button
Transcribed Image Text:The flowchart titled "Secret Code" outlines a process for creating and printing an encrypted word using random sampling and string manipulation. Here’s a detailed explanation of each step: 1. **Start**: - The process begins with the "Secret Code" initiation. 2. **Import Libraries**: - Import the `random` and `string` modules, which are essential for randomization and handling string data. 3. **Create Array for Index**: - Initialize an array to hold index values that will be used for encryption. 4. **Assign Random Sample to Array**: - Populate the index array with a random sample to generate a key for encryption. 5. **Create Array for Alphabet**: - Create an array consisting of the alphabet, which will be referenced to assign letters during encryption. 6. **Decision: End of Word**: - A decision point checks whether the end of the word has been reached. - **If Yes**: - Proceed to print the encrypted word. - **If No**: - Continue with the following steps. 7. **Assign Letter Index**: - Determine the index of the current letter for processing. 8. **Print Letter Information**: - Output the current letter, its old index, and the new index for tracking purposes. 9. **Concatenate New Encrypted String**: - Append the modified letter to form the new encrypted string. 10. **Repeat Process**: - Loop back to the decision point to process the next letter until the entire word is encrypted. 11. **End**: - The process concludes with the encrypted word being printed out. This flowchart effectively demonstrates a simple method for encrypting a word by reassigning letters based on randomized indices, showcasing basic encryption logic utilizing Python libraries.
Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education