Answer:
a. cout<<hidden(15,10)<<endl;
output = 5
b. cout << compute(3, 9) << endl;
output=3
c. cout << hidden(30, 20) << " " << compute(10, hidden(30, 20)) << endl;
output = 10
d. x = 2; y = 8; cout << compute(y, x) << endl;
output= 8
Explanation:
solution a:
num1= 15;
num2= 10;
according to condition 1, num1 is not greater than 20. In condition 2, num2 is also not greater than 20.
so,
the solution is
return num1 - num2 = 15 - 10 = 5
So the output for the above function is 5.
solution b:
as in function there are two integer type variables named as one and two. values of variables in given part are:
one = 3
two = 9
secret = one = 3
for (int i= one + 1 = 3+1 = 4; i<=9%2=1; i++ )
9%2 mean find the remainder for 9 dividing by 2 that is 1.
// there 4 is not less than equal to 1 so loop condition will be false and loop will terminate. statement in loop will not be executed.
So the answer will be return from function compute is
return secret ;
secret = 3;
so answer return from the function is 3.
solution c:
As variables in first function are num1 and num2. the values given in part c are:
num1 = 30;
num2= 20;
According to first condition num1=30>20, So,
num1= num2/10
so the solution is
num1 = 20/10 = 2
now
num1=2
now the value return from function Hidden is,
return num1*num2 = 2* 20 = 40
Now use the value return from function hidden in function compute as
compute(10, hidden(30, 20))
as the value return from hidden(30, 20) = 40
so, compute function becomes
compute(10, 40)
Now variable in compute function are named as one and two, so the values are
one= 10;
two = 40;
as
secret = one
so
secret = 10;
for (int i= one + 1 = 10+1 = 11; i<=40%2=0; i++ )
40%2 mean find the remainder for 40 dividing by 2 that is 0.
// there 11 is not less than equal to 0 so loop condition will be false and loop will terminate. statement in loop will not be executed.
So the answer will be return from function compute is
return secret ;
secret = 10;
so answer return from the function is 10.
solution d:
Now variable in compute function are named as one and two, so the values are
one = y = 8
two = x = 2
There
Secret = one = 8;
So
for (int i= one + 1 = 8+1 = 9; i<=2%2=0; i++ )
2%2 mean find the remainder for 2 dividing by 2 that is 0.
// there 9 is not less than equal to 0 so loop condition will be false and loop will terminate. statement in loop will not be executed.
So the answer will be return from function compute is
return secret ;
secret = 8;
so answer return from the function is 8.
Answer:
public class TestSoccerPlayer {
public static void main(String[] args) {
SoccerPlayer playerOne = new SoccerPlayer("Rinco",9,16,22);
System.out.println("The player of the season is "+playerOne.getName()+" His Jessey Number is "+playerOne.getJerseyNum()
+" In the 2019/2020 season he scored and total of "+playerOne.getGoalsScored()+" and "+
playerOne.getAssists()+" Asists");
}
}
See the SoccerPlayer class with the feilds and methods (constructor, getter and setters) in the explanation section
Explanation:
public class SoccerPlayer {
private String name;
private int jerseyNum;
private int goalsScored;
private int assists;
public SoccerPlayer(String name, int jerseyNum, int goalsScored, int assists) {
this.name = name;
this.jerseyNum = jerseyNum;
this.goalsScored = goalsScored;
this.assists = assists;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getJerseyNum() {
return jerseyNum;
}
public void setJerseyNum(int jerseyNum) {
this.jerseyNum = jerseyNum;
}
public int getGoalsScored() {
return goalsScored;
}
public void setGoalsScored(int goalsScored) {
this.goalsScored = goalsScored;
}
public int getAssists() {
return assists;
}
public void setAssists(int assists) {
this.assists = assists;
}
}
B. False
Answer:
A. True
Explanation:
B. Discuss whether such an attack would succeed in systems protected by SSL.
Answer:
A. No, it would not succeed.
B. Yes, the attack will succeed.
Explanation:
In the seven-layer OSI model of computer networking, packet strictly refers to a protocol data unit at layer 3, the network layer. So if an attacker wants to insert bogus/ fake packets this will happen at the network layer.
A. IPSec works on network layer (the IP layer) of the OSI model protecting and authenticating IP packets. It provides data integrity, authentication and confidentiality between participating peers at the IP layer.
Thus, inserting bogus packets into the communications by an attacker will not have any affect on security of a system which has IPSec security and therefore it will not succeed.
B. SSL/TLS is an application layer protocol that fits into layer 5 to 7 of the OSI model. However, an attack by inserting bogus packets into the communications will succeed as SSL only provides protection for layer 5 to 7 and not the network layer.
Explanation:
I/O (input/output)" describes any operation, program, or device that transfers data to or from a computer
Answer:
Explanation:
#include <iostream>
#include <string>
#include<vector>
using namespace std;
vector<int> permute(vector<int>, vector<int>);
string encrypt(vector<int>s1 , vector<int> t1, string p);
string decrypt(vector<int>s1, vector<int> t1, string p);
int main() {
string plaintext = "cryptology";
string plaintext2 = "RC4";
vector<int> S(256);
vector<int> T(256);
int key[] = { 1,2,3,6 };
int key2[] = { 5,7,8,9 };
int tmp = 0;
for (int i = 0; i < 256;i++) {
S[i] = i;
T[i] = key[( i % (sizeof(key)/sizeof(*key)) )];
}
S = permute(S, T);
for (int i = 0; i < 256 ;i++) {
cout << S[i] << " ";
if ((i + 1) % 16 == 0)
cout << endl;
}
cout << endl;
string p = encrypt(S, T, plaintext);
cout << "Message: " << plaintext << endl;
cout << "Encrypted Message: " << " " << p << endl;
cout << "Decrypted Message: " << decrypt(S, T, p) << endl << endl;
tmp = 0;
for (int i = 0; i < 256;i++) {
S[i] = i;
T[i] = key2[(i % (sizeof(key) / sizeof(*key)))];
}
S = permute(S, T);
for (int i = 0; i < 256;i++) {
cout << S[i] << " ";
if ((i + 1) % 16 == 0)
cout << endl;
}
cout << endl;
p = encrypt(S, T, plaintext2);
cout << "Message: " << plaintext2 << endl;
cout << "Encrypted Msg: " << p << endl;
cout << "Decrypted Msg: "<<decrypt(S, T, p) << endl << endl;
return 0;
}
string decrypt(vector<int>s1, vector<int> t1, string p) {
int i = 0;
int j = 0;
int tmp = 0;
int k = 0;
int b;
int c;
int * plain = new int[p.length()];
string plainT;
for (int r = 0; r < p.length(); r++) {
i = (i + 1) % 256;
j = (j + s1[i]) % 256;
b = s1[i];
s1[i] = s1[j];
s1[j] = b;
tmp = (s1[i] + s1[j]) % 256;
k = s1[tmp];
c = ((int)p[r] ^ k);
plain[r] = c;
plainT += (char)plain[r];
}
return plainT;
}
string encrypt(vector<int>s1, vector<int> t1, string p) {
int i = 0;
int j = 0;
int tmp = 0;
int k = 0;
int b;
int c;
int * cipher = new int [p.length()];
string cipherT;
cout << "Keys Generated for plaintext: ";
for (int r = 0; r < p.length(); r++) {
i = (i + 1) % 256;
j = (j + s1[i]) % 256;
b = s1[i];
s1[i] = s1[j];
s1[j] = b;
tmp = (s1[i] + s1[j]) % 256;
k = s1[tmp];
cout << k << " ";
c = ((int)p[r] ^ k);
cipher[r] = c;
cipherT += (char)cipher[r];
}
cout << endl;
return cipherT;
}
vector<int> permute(vector<int> s1, vector<int> t1) {
int j = 0;
int tmp;
for (int i = 0; i< 256; i++) {
j = (j + s1[i] + t1[i]) % 256;
tmp = s1[i];
s1[i] = s1[j];
s1[j] = tmp;
}
return s1;
}
Answer: (A) Firewall; implement an ACL on the interface
Explanation:
According to the question, for re-mediate the issue firewall should be implemented the ACL (Access control list) on the given interface. The access control list is one of the type of logic which selectively give permission or deny the number of packet in the system which to through the interface.
Firewall is the type of device that basically examine the traffic in the network system and also make several decisions in the system. ACL is the set of rule which mainly define the route of the packet in the router interface state.