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

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

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