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

What is the output of the following code snippet? (If there is some kind of syntax...
What is the output of the following code snippet? (If there is some kind of syntax error indicate this by marking "error" in your answer choice) 1.        int laps = 8;        if (laps++ > --laps)               laps += 2;        else if (--laps > (laps - 1))               laps += 4;        else if (++laps)               laps -= 3;        cout << laps << endl; 2. What is the output of the following code snippet?     int j = 47;     int i = 8;     j =...
this code still shows that it still has an syntax error in it can you please...
this code still shows that it still has an syntax error in it can you please fix it. I will put an error message next to the line that is wrong and needs fixed, other than that the other lines seems to be ok. public static void main() { /** * main method - makes this an executable program. */ public static void main("String[]args"); this is the error line that I get and needs fixed // create a client with...
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...
C++ : Find the syntax errors in the following program. For each syntax error, fix it...
C++ : Find the syntax errors in the following program. For each syntax error, fix it and add a comment at the end of the line explaining what the error was. #include <iostream> #include <cmath> using namespace std; int main(){ Double a, b, c; 2=b; cout<<"Enter length of hypotenuse"<<endl; cin>>c>>endl; cout>>"Enter length of a side"<<endl; cin>>a; double intermediate = pow(c, 2)-pow(a, 2); b = sqrt(intermediate); cout<<"Length of other side is:" b<<endline; return 0; }
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...
Look at the C code below. Identify the statements that contain a syntax error OR logical...
Look at the C code below. Identify the statements that contain a syntax error OR logical error. Evaluate each statement as if all previous statements are correct. Select all that apply                 #include <stdio>                 Int main()                 {                                 Float webbing;                                 Puts(“Please enter the amount of webbing per cartridge: “)                                 Scanf(“%f”, webbing);                                 Printf(“You entered: “+ webbing + “\n”);                                 Return 0;                 } Answers:                 Including the library for I/O                 Declaring a variable                 Writing...
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,...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT