Python: How to Fix “Ord() expected string of length 1, but int found”

code as follows:

import base64

def decode(ciphertext):
	plaintext = ''
	ciphertext = base64.b64decode(ciphertext)
	for i in ciphertext:
		s = ord(i)-16 ######################
		s = s^32
		plaintext += chr(s)
	return plaintext

cipher = 'XlNkVmtUI1MgXWBZXCFeKY+AaXNt'
flag = decode(cipher)
print(flag)

In python3, running

with a hash sign will fail and python2 won’t, because in python3 the ord() accepts a string of length 1, whereas in python3 the I is already an integer, and you can just use i-16 to do the operation

Python3 ord() expected string of length 1, but int found

Read More: