Write a psudocode:
1. Define a function called authorize that takes in 2 strings, uName, and passwd, as arguments and produces a Boolean as output. Your function should output True if both the username is “batman” and the password is “rulz” and false in any other situation. (KEEP IN MIND: this function didn’t say anything about looping. It performs authentication on only 1 pass)
Pseudo code:
def authorize(uName,passwd) //define the function
{
if(uName=='batman' and passwd=='rulz') return true; //check the condition
else return false;
}
print(authorize('batman','rulz')) //check the output by printing
Python code:
def authorize(uName,passwd):
if(uName=='batman' and passwd=='rulz'):
return True
else:
return False
user_name = input() #username
pass_word = input() #password
print(authorize(user_name,pass_word))
C code:
#include <stdio.h>
#include<string.h>
#include<stdbool.h>
int authorize(char *uName,char *passwd)
{
if(strcmp(uName,"batman")==0 && strcmp(passwd,"rulz")==0)
return 1;
else return 0;
}
int main()
{
int a = authorize("batman","rulz1");
if(a==1) printf("True");
else printf("False");
return 0;
}
I have given the pseudo-code and python code, C code for your reference. As you did not mention a particular language, I have given python and C code. The pseudo-code is the same for any programming language. There is no use of a loop for the validation here, only an if-else statement is required. I hope you find this helpful.
Write a psudocode: 1. Define a function called authorize that takes in 2 strings, uName, and...
Guessing one password: write a function called guess that takes a string (a guessed password) as an argument and prints out matching information if its encrypted string matches any of the strings in the encrypted password file. When you write the function, you may hardcode the name of the password file. Here is an example run: >>> guess("blue") Found match: blue Line number: 1 Encrypted value: 16477688c0e00699c6cfa4497a3612d7e83c532062b64b250fed8908128ed548 You will want to use the encrypt function presented in class: import hashlib...
Question 1 A hash function takes a ____________ length input and returns a _________ length output variable / fixed fixed / variable variable / variable fixed / fixed Question 2 What is the one way property of cryptographic hash functions? h:hash value, M: message easy to compute h from f(M) easy to compute M from h hard to compute h from f(M) simple structure of the function f Question 3 There're two type of collision resistance : weak and strong...
PYTHON 1.Guessing many passwords: Write a function called guess_passwords. It doesn't take any arguments. It should use the function guess, trying out as many possible passwords as possible. Here are some methods you might try: Try out a hardcoded list of strings that you think people might use as passwords. Try out all words in the word file. Try out all character combinations of length 4 or less (or more if you don't mind waiting). Try out combinations of words...
Python
1 Write a function called sum_odd that takes two parameters, then calculates and returns the sum of the odd numbers between the two given integers. The sum should include the two given integers, if they are odd. You can assume the arguments will always be positive integers, and the first smaller than or equal to the second. 3 To get full credit on this problem, you must define at least 1 function, use at least 1 loop, and use...
0. Introduction. This involves designing a perfect hash function for a small set of strings. It demonstrates that if the set of possible keys is small, then a perfect hash function need not be hard to design, or hard to understand. 1. Theory. A hash table is an array that associates keys with values. A hash function takes a key as its argument, and returns an index in the array. The object that appears at the index is the key’s...