defa(num):if (num>1):foriinrange(2,num):#From all numbers from 2 to num - 1
if (num%i)==0:#check if the number i divides num
returnFalse#if it divides, then its composite
breakreturnTrue# No such number found hence prime
else:returnFalse
Seems like, its looping over all possible numbers to check if the provided number num is a prime or not
Python
1
2
3
4
5
6
7
defb(num):my_str=str(num)# string representation of number
rev_str=reversed(my_str)# reverse the string
iflist(my_str)==list(rev_str):# check if both equal
returnTrue# the input is a palindrome
else:returnFalse
It is simply taking number from the list and xoring with next prime-palindrome to give the character in sets of 13. Lets simply run the decrypt.py to see what happens
Plain text
1
2
python3 decrypt.py
flag{pR1m3s_4re_co0ler_Wh3
Hmm, seems stuck. What’s the issue?
The issue is with function a which checks for prime by dividing it by all numbers.
This can be done pretty efficiently by better primality tests.
One could simply use is_prime from gmpy2 library of python and replace the function a