Hi and I am making a script but am having a slight math logic problem. Below is an example of an encoder I am working on.

```
for(int m=0;m<80;m++)
{
if(m<=19)
{
f = (b & c) | ((~b) & d);
k = 0x5A827999;
}
else if(m<=39)
{
f = b ^ c ^ d;
k = 0x6ED9EBA1;
}
else if(m<=59)
{
f = (b & c) | (b & d) | (c & d);
k = 0x8F1BBCDC;
}
else
{
f = b ^ c ^ d;
k = 0xCA62C1D6;
}
temp = (rotateleft(a,5) + f + e + k + word[m]) & 0xFFFFFFFF;
e = d;
d = c;
c = rotateleft(b,30);
b = a;
a = temp;
}
```

Then below is the decoder. The decoder is meant to reverse the math but can't seem to get the value of variable e. However I do know the value of e on the first and last loop rounds but all other loop rounds e needs to be calculated. Does anybody know what I'm doing wrong because I can't seem to figure it out? Below is what I have tried and although all is fine e is unknown making the whole script go crazy.

```
for (int m=79; m>=0; m--) {
temp = a;
a = b;
b = rotateright(c,30);
c = d;
d = e;
if(m<=19)
{
f = (b & c) | ((~b) & d);
k = 0x5A827999;
}
else if(m<=39)
{
f = b ^ c ^ d;
k = 0x6ED9EBA1;
}
else if(m<=59)
{
f = (b & c) | (b & d) | (c & d);
k = 0x8F1BBCDC;
}
else
{
f = b ^ c ^ d;
k = 0xCA62C1D6;
}
}
```

Thanks.