Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //podatki
- $n = 187; //modul
- $javni = 7; //javni kjuc
- //zlomi kjuc
- $a = 2;
- while ($a < $n)
- {
- if($n % $a ==0)
- {
- break;
- }
- $a++;
- }
- $p = $a;
- $q = $n / $a;
- $n = $p * $q; //modul
- $o = ($p-1)*($q-1); //koeficient
- $x = 0;
- $y = 1;
- $lastx = 1;
- $lasty = 0;
- $a = $o;
- $b = $javni;
- while($b !=0)
- {
- $quotient = intval($a / $b);
- $temp = $a;
- $a = $b;
- $b = bcmod($temp,$b);
- $temp = $x;
- $x = ($lastx - $quotient * $x);
- $lastx = $temp;
- $temp = $y;
- $y = ($lasty - $quotient * $y);
- $lasty = $temp;
- }
- if($lasty <0)
- {
- $lasty = $o - $lasty;
- }
- echo 'N (modul) je '.$n.'<br>Zasebni kjuc je '.$lasty.'<br>Javni kjuc je '.$javni;
- ?>
Add Comment
Please, Sign In to add comment