I'm trying to print this the return of this function in the same order it is defined in:
import numpy
def Decrypt_CRT_RSA(c, d, p, q):
"""
Decrypts RSA with CRT
:param c: The cipher text you want to decrypt
:param d: The secret key
:param p: A prime number forming half of the secret key
:param q:A prime number forming the other half of the secret key
"""
dp = d % (p - 1)
dq = d % (q - 1)
cp = c % p
cq = c % q
m0 = pow(cp, dp, p)
m1 = pow(cq, dq, q)
Msg = CRT([m0, m1], [p, q])[0]
return {
'p part of the cipher text: ' + str(cp),
'q part of the cipher text: ' + str(cq),
'p part of the private key: ' + str(dp),
'q part of the private key: ' + str(dq),
'first half of the message m: ' + str(m0),
'second half of the message m: ' + str(m1),
'the full message (aka m0 + m1): ' + str(Msg)
}
c = 64649
d = 241187
p = 659
q = 673
print(Decrypt_CRT_RSA(c, d, p, q))
but it is printed like this:
{'p part of the cipher text: 67', 'the full message (aka m0 + m1): 12345', 'first half of the message m: 483', 'q part of the private key: 611', 'second half of the message m: 231', 'p part of the private key: 359', 'q part of the cipher text: 41'}
And as you can see the second thing printed is the one starting with the full message
which is the one I return last. How do i get python to respect the return as defined by the function? Or even better, return in the same way it is defined (aka each entry on a new line)