In: Computer Science
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()
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