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:
- How to Fix “junit.framework.Comparison Failure Expected: but was”
- Type error: sequence item 0: expected STR instance, int found
- A repeated string is composed of two identical strings. For example, abcabc is a repeated string with length of 6, while abcba does not have a duplicate string. Given any string, please help Xiaoqiang find the longest repeated substring.
- The reason and solution of the error of join function: sequence item 0: expected STR instance, int found
- How to Fix distributed training report terminate called after throwing an instance of’std::length_error’
- Expected indentation of 6 spaces but found 10
- Err: error parsing query: found name, expected identifier, string
- RuntimeError: Found dtype Double but expected Float”
- error Expected indentation of 2 spaces but found 8
- How to Fix Pandoc wasn’t found.pdflatex not found on PATH
- Solve the runtimeerror in RNN: expected scalar type long but found float error
- RuntimeError: expected scalar type Double but found Float
- In Java, int is converted to string, and zero is added before the number of bits is insufficient
- How to Fix Error in python3 | PIP install Dlib
- TypeError: int() can’t convert non-string with explicit base
- An error was reported on the command line of Vue when it first wrote a small project: expected indentation of 4 spaces but found 6
- How to Fix Parser rerror: error tokenizing data. C error: expected 2 fields in line 53, saw 3
- Undefined reference to ‘CV:: imread (CV:: String const & int)’
- Differences between length() size() and C strlen() of C + + string member functions
- How to Fix Sklearn ValueError: This solver needs samples of at least 2 classes in the data, but the data