Calculate the key and compare the value to key if the two


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.

Request for Solution File

Ask an Expert for Answer!!
Computer Engineering: Calculate the key and compare the value to key if the two
Reference No:- TGS02879107

Expected delivery within 24 Hours