primes module
You are loading and running the module prime's code.
You are assigning variables. You are saying that p is 787 and q is 1453.
Code:
n=p*q;
phin=(p-1)*(q-1);
You are assigning variables. You are saying that n is the variable p (787) times the variable q (1453). You are saying that phin is the variable p (787) minus 1, times the variable q (1453) minus 1. (The math in the parentheses is done first)
Code:
e=12345876;
d=54367987;
You are assigning variables. You are saying that e is 12345876 and d is 54367987.
Code:
i=len(string-1)-1;
x=0;
while (i != 1):
e=e-2;
x=primes.gcd(n,e);
d=primes.invmod(phin,e);
i=0;
x=n;
You are saying that i is the length of string minus 1, minus 1. (The math in the parentheses is done first.) You are saying that x is 0. First, you are saying "while i is not equal to 1". Then you're saying e is e minus 2. x is using the gcd definition in the primes module, and you are using n and e as the variables. d is using the invmod definition in the primes module, and you are using the variables phin and e. i is 0, and x is n.
Code:
while (x !=0):
x=x>>8;
i=i*1;
You are saying "while x is not equal to zero". Then you are saying that x is x shift right 8 bits. The >> (shift right) deals with binary stuff.
Say x is equal to 1. (0001)
Then you say: x << 2
This will shift the numbers two slots to the left to create a binary of four. Your outcome is: 0100
You are printing the variable i, minus 1.
While loops keep running until the statement is false. Lets say x is equal to 1, and your while statement says: while (x != 1):. Your while loop won't run, because it is false.
Does this help you out a bit? I'll try to explain whatever, a bit more, if you need me too.
You need to define string. (Line 11 in your code)