cwarn23 Posted February 26, 2010 Share Posted February 26, 2010 Hi, I am trying to reverse a loop but am having some troubles. Below is an example of my problem but I need to find the value of $c in each round of the second loop. Does anybody know how to find the value of $c in the second loop because I'm stuck in the middle of thick woods. <?php $a=1; $b=47; $c=88; $tmp=23; for($i=0;$i<80;$i++) { $random_number=floor(mt_rand(0,1000)); echo $random_number.'<br>'; $tmp=($tmp+$c+$random_number)*0.5; $c=$b; $b=$a; $a=$tmp; } //Now to reverse echo '<hr>'; $tmp=$a; for ($i=0;$i<80;$i--) { $a=$b; $b=$c; //$c=(unknown); //$random_number=(($tmp-$c)-$a)*2; //$tmp=($tmp-(($random_number*0.5)+$c+$a))*2; //echo $random_number.'<br>'; } ?> Also the objective in this script is to find $random_number for each loop round by appending new code instead of altering the original. Thanks. Quote Link to comment Share on other sites More sharing options...
cwarn23 Posted February 26, 2010 Author Share Posted February 26, 2010 Just an update, I saw that code has an infinit loop so it is as follows. <?php $a=1; $b=47; $c=88; $tmp=23; for($i=0;$i<80;$i++) { $random_number=floor(mt_rand(0,1000)); echo $random_number.'<br>'; $tmp=($tmp+$c+$random_number)*0.5; $c=$b; $b=$a; $a=$tmp; } //Now to reverse echo '<hr>'; $tmp=$a; for ($i=0;$i<80;$i++) { $a=$b; $b=$c; //$c=(unknown); //$random_number=(($tmp-$c)-$a)*2; //$tmp=($tmp-(($random_number*0.5)+$c+$a))*2; //echo $random_number.'<br>'; } ?> And why isn't anyone replying. Quote Link to comment Share on other sites More sharing options...
teamatomic Posted February 27, 2010 Share Posted February 27, 2010 I have not replied cause what you are doing is greek to me. You loop through 80 times displaying a random number while doing a bunch of other greeky stuff that does nothing to the results of the random number and that you never use elsewhere. Whats to answer? HTH Teamtomic Quote Link to comment Share on other sites More sharing options...
gizmola Posted February 27, 2010 Share Posted February 27, 2010 cwarn: i thought we went over this in irc. What you are doing is a dead end. You can not reverse a sha1 hash and "decrypt" it. It is a hash, not encrypted ciphertext. Quote Link to comment Share on other sites More sharing options...
cwarn23 Posted February 27, 2010 Author Share Posted February 27, 2010 Whats to answer? Basically I need to find the value of $c and $c is the same as what $tmp will be in two loops time. So I need to predict what $tmp will be in two loops time and assign it to $c. Does anyone know how to do that as it would solve not only this problem but part of a bigger problem I am dealing with. Surly something as simple as this can be solved. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.