Question

In: Computer Science

The following code has some syntax error. Please fixed the error. Besides, I want the output...

The following code has some syntax error. Please fixed the error. Besides, I want the output in ASCII characters. Please give me the corrected code along with the screenshot of the output.

def cbc_dec(ys):

int xs = []

int iv = ("0XAA", 16) #in decimal

int key = ("0X08", 16)

int x0 = chr(((163 * (int (ys[0], 16) - key)) % 256) ^ iv)

xs.append(x0)

for i in range (1, len(ys)):

int xi = chr((( 163 * (int (ys[i], 16) - key)) %256) ^ int (ys[i-1], 16))

xs.append(xi)

return xs

def main():

cipher_cbc = ["0XA0", "0XCC", "0X1F","0XE3','0XE0','0X59']

ps_cbc = cbc_dec(cipher_cbc)

print("\nCBC decryption", ps_cbc)

main()

Solutions

Expert Solution

def cbc_dec(ys):
    xs = list()

    iv = int("0XAA", 16) #in decimal

    key = int("0X08", 16)

    x0 = chr(((163 * (int(ys[0], 16)-key)) % 256) ^ iv)

    xs.append(x0)

    for i in range (1, len(ys)):

        xi = chr((( 163 * (int (ys[i], 16) - key)) %256) ^ int(ys[i-1], 16))

        xs.append(xi)

    return xs

def main():

    cipher_cbc = ["0XA0", "0XCC", "0X1F","0XE3","0XE0","0X59"]

    ps_cbc = cbc_dec(cipher_cbc)

    print("\nCBC decryption", ps_cbc)

main()

Screenshot


Related Solutions

For each of the following Visual Basic code snippets, identify the syntax error.   If intX >...
For each of the following Visual Basic code snippets, identify the syntax error.   If intX > 100   lblResult.Text = "Invalid Data" End If   Dim str As String = "Hello" Dim intLength As Integer intLength = Length(str) If intZ < 10 Then   lblResult.Text = "Invalid Data"   Dim str As String = "123" If str.IsNumeric Then   lblResult.Text = "It is a number." End If   Select Case intX   Case < 0     lblResult.Text = "Value too low."   Case > 100     lblResult.Text = "Value too high."   Case Else     lblResult.Text = "Value...
a) i) The following VHDL code contains erroneous syntax. Re write the code in its corrected...
a) i) The following VHDL code contains erroneous syntax. Re write the code in its corrected format onto your answer sheet. You may assume that din is a 16-bit vector and that the ld, lr and cl inputs are 1-bit wide. lp: process(clk) signal reg : std_logic_vector(15 downt begin if cl=’1’ then reg := (others:=’0’); else if clk=’1’ and clkevent then if ld=’1’ reg <= din; end if; if lr=’1’ then reg := reg(14 downto 0) & “0 else reg...
Syntax error in C. I am not familiar with C at all and I keep getting...
Syntax error in C. I am not familiar with C at all and I keep getting this one error "c error expected identifier or '(' before } token" Please show me where I made the error. The error is said to be on the very last line, so the very last bracket #include #include #include #include   int main(int argc, char*_argv[]) {     int input;     if (argc < 2)     {         input = promptUserInput();     }     else     {         input = (int)strtol(_argv[1],NULL, 10);     }     printResult(input);...
C++ i want .00 at the output cout << fixed << setprecision (2);where should i put...
C++ i want .00 at the output cout << fixed << setprecision (2);where should i put this line? quesstion 13. Array of Payroll Objects Design a PayRoll class that has data members for an employee’s hourly pay rate and number of hours worked. Write a program with an array of seven PayRoll objects. The program should read the number of hours each employee worked and their hourly pay rate from a file and call class functions to store this information...
Using SAS programming Please include the syntax and output of the information: In a study of...
Using SAS programming Please include the syntax and output of the information: In a study of factors thought to be responsible for the adverse effects of smoking on human reproduction, cadmium level determinations (nanograms per gram) were made on placenta tissue of a sample of 14 mothers who were smokers and an independent random sample of 18 nonsmoking mothers. The results were as follows- Nonsmokers: 10.0, 8.4, 12.8, 25.0, 11.8, 9.8, 12.5, 15.4, 23.5, 9.4, 25.1, 19.5, 25.5, 9.8, 7.5,...
Using SAS programming Please include the syntax and output of the information: In a study of...
Using SAS programming Please include the syntax and output of the information: In a study of factors thought to be responsible for the adverse effects of smoking on human reproduction, cadmium level determinations (nanograms per gram) were made on placenta tissue of a sample of 14 mothers who were smokers and an independent random sample of 18 nonsmoking mothers. The results were as follows- Nonsmokers: 10.0, 8.4, 12.8, 25.0, 11.8, 9.8, 12.5, 15.4, 23.5, 9.4, 25.1, 19.5, 25.5, 9.8, 7.5,...
please correct the error and fix this code: (i need this work and present 3 graphs):...
please correct the error and fix this code: (i need this work and present 3 graphs): Sampling_Rate = 0.00004; % which means one data point every 0.001 sec Total_Time = 0:Sampling_Rate:1; % An array for time from 0 to 1 sec with 0.01 sec increment Omega = 49.11; % in [rad/s] zeta=0.0542; %unitless Omega_d=49.03; % in [rad/s] Displacement_Amplitude = 6.009; % in [mm] Phase_Angle = 1.52; % in [rad] Total_No_of_Points = length(Total_Time); % equal to the number of points in...
Problem with code. The fixed code would be greatly appreciated! Error messages: PlayerMoveDungeon2.java:21: error: cannot find...
Problem with code. The fixed code would be greatly appreciated! Error messages: PlayerMoveDungeon2.java:21: error: cannot find symbol for (i = 0; i < length; i++) { ^ symbol: variable i location: class PlayerMoveDungeon2 PlayerMoveDungeon2.java:21: error: cannot find symbol for (i = 0; i < length; i++) { ^ symbol: variable i location: class PlayerMoveDungeon2 PlayerMoveDungeon2.java:21: error: cannot find symbol for (i = 0; i < length; i++) { ^ symbol: variable i location: class PlayerMoveDungeon2 PlayerMoveDungeon2.java:22: error: cannot find symbol...
C++ program. Please explain how the code resulted in the output. The code and output is...
C++ program. Please explain how the code resulted in the output. The code and output is listed below. Code: #include <iostream> #include <string> using namespace std; int f(int& a, int b) {    int tmp = a;    a = b;    if (tmp == 0) { cout << tmp << ' ' << a << ' ' << b << endl; }    b = tmp;    return b;    return a; } int main() {    int a...
identify the syntax errors in the following code:             public class Hello {                    &
identify the syntax errors in the following code:             public class Hello {                         private static int main(String [] args) {                                     string Msg=”Hello, Wrld!;                                     Sytem.out.println(msg+ “Ken")
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT