Calculate the key and compare the value

Assignment Help Computer Engineering
Reference no: EM132085648

One important aspect of security in computer science is the concept of hashing : taking some text, and somehow converting it to a number. This is needed because many security algorithms work through math, so numbers are needed. Another important aspect is the use of the modulo operator (%). Yo u've seen this -- it returns the remainder portion of a division.

This is useful because unlike most other math operators, modulo is one - way. That is, I can tell you that I'm thinking of a number x , and when I mod it by 5, I get 3, but from this informatio n alone, you don't know whether x is 3 or 8 or 13 or 18, or ... In this problem, we'll create a login screen, where the user must enter a password in order to see a secret message. We will give the user 3 chances to get the password right, and either prin t the secret message or a failure message (after 3 chances).

PYTHON PROGRAMMIG .

First, write a program that takes one string. It will hash the string using the built - in Python function hash (try it on the shell) and modulo the value by a prime number (e.g. 541 -- this is very small in the computer science world but good enough for us).

The program should then print this number. e.g. It should print 211 (result) when the string is "mypassword " (if you use 541 as the prime, for example) At the top of the file, define a variable _KEY to be the re sult .

Now, write the rest of the program. Each time you ask the user for the password, ask for the user's input, calculate the key and compare the value to _KEY . If the two match, the user (most likely) entered the correct password, otherwise he loses one chance.

Reference no: EM132085648

Questions Cloud

The purposes of backup and recovery and business continuity : What steps would you take to "stratify and prioritize" information for the purposes of backup and recovery, and business continuity?
Write code to count how many times the string hello : Create a cell array, C, containing the strings: 'hello' 'goodbye' 'hello' 'hello goodbye' 'goodbye' 'hello' 'goodhellow' 'see you in hell'.
Genre for modern chinese literature : Why are "Diary of a Mad Man" and "The Man of La Mancha" an especially important genre for modern Chinese literature?
Write a function that returns a string reversed : Write a function that returns a String reversed. That is, if the word is program, then the function will return margorp.
Calculate the key and compare the value : Calculate the key and compare the value to _KEY . If the two match, the user (most likely) entered the correct password, otherwise he loses one chance.
What is the coefficient of linear expansion : He notices that at this new temperature, the bar's length has increased by 1.422 × 10^-3 m. What is the coefficient of linear expansion (a) for the new alloy?
Compare ada and java in given regard : Where must the representation details be placed? Compare Ada with both C++ and Java in this regard.
What is the rms speed of the dust particles : Dust grains of diameter 0.24 µm and density 1000 kg/m3 are in equilibrium with air (A = 28.9) at a temperature of 270 K . What is the rms speed of the dust part
Write a test bench to simulate the given operation : Using Xilinx ISE, write and simulate a VHDL/Verilog description to correctly command the lights according to the occupancy of the parking lot.

Reviews

Write a Review

Computer Engineering Questions & Answers

  What connection can you make to previous learning experience

From what you know about this course so far, what connections can you make to previous learning experiences, and how do you think this course will help you as you move forward in your college and professional life?

  Design "getter" methods for make and color

make a printAll() method. In this method, print the color and make of the automobile on one line in accordance to the sample session given below.

  Create a function that replaces a passed string in a list

Create a function that replaces a passed string in a list of strings with a new string. Are the numbers returned from random. random() function really random?

  What is oracle administration documentations

What is oracle administration documentations

  Conduct research and provide a two page apa response

1.conduct research and provide a two page apa response. describe and discuss the following topics regarding nonlinear

  Develop an opinion as to the degree to which hypertext links

Select two opposing viewpoints from web sources and by providing a review of their content develop an opinion as to the degree to which hypertext links are a good idea.

  In what sense is the hci experience creative and dialogical

In what sense is the HCI experience creative and dialogical? Please remember to focus on the user. If the self is always-emerging, how does your project help?

  Your boss has just heard about some nefarious computer

your boss has just heard about some nefarious computer activities known ping sweeps and port scans. he wishes to know

  What would be the average disk access time on your system

What would be the average disk access time on your system using a RAID-5 array with two sets of four disks if 25% of the database transactions must wait behind one transaction for the disk to become free?

  Write an algorithm for driving from where you live

Write an algorithm for driving from where you live to the nearest airport that has regularly scheduled flights.

  Discuss in detail the role that an ids or ips would play

Discuss in detail the role that an IDS / IPS would play in the IR efforts, and explain how these systems can assist in the event notification.

  Describe the concept of first-come first-serve basis

Persons arrive at a Xerox machine according to a Poisson process with rate one per minute. The number of copies to be made by each person is uniformly.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd