V
V
Vladimir Shiklgruber2015-03-20 18:24:03
PHP
Vladimir Shiklgruber, 2015-03-20 18:24:03

Adds an extra number. How to fix?

Hello. I am making a game portal, the games are all on different servers. Curl I give commands. Everything works fine. Now I started worrying about security. the choice fell on xxtea (there was a ready-made solution in the net) I made a key encryption for xxtea.

//ключ для xxtea
                $sekret = mt_rand(1,99999999999999);
        

//фальшыфка для get :D пускай тру хакеры помучаются пару недель :D

                $sol = mt_rand (1, 9999999);
                $iid = mt_rand (1, 900);
                $iid = md5($sol.$iid.sha1($sekret.$iid).md5($sol.$iid));
                $dan = base64_encode($iid);
                $dan = md5($sol.$iid.$dan.sha1($sekret.$iid.$dan).md5($sekret.$iid.$dan));
//шифровка ключа который делает розшыфровку :D знаю что  так надёжние :D :D

                $pi = mt_rand (1, 5);
                $delitil = mt_rand (1, 10);            
                $mnogitel = mt_rand (1, 15);
                $dodan = mt_rand (1, 20);
                $mn = mt_rand (1, 25);
                $mn1 = mt_rand (1, 50);
                $procent = mt_rand (1, 5);

                $procent= $sekret / $procent;
                $sekret = $sekret * $mn / $pi;         
                $pq = $sekret / $delitil;
                $pw = $pq /$procent;
                $output = $pw * $mnogitel ;
                $otv = $output + $dodan * $mn1;
//розшыфровка ключа
$otv = $output / $mn1 - $dodan;
$sekret =$output * $procent * $delitil / $mnogitel /$mn * $pi;

The problem is that the servers have different settings for the accuracy of calculations (I have 777 on my server and 777.998 on remote)
I thought I thought I decided to round it up and added
$sekret = round($sekret);
Now it works more stably. but since all the numbers are random, in some cases the remote makes 778 instead of 777. How can this be dealt with?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
O
Oleg, 2015-03-20
@aaadddminnn

use not round but floor/ceil if it doesn't matter what the number is
or (int) $var

M
Maxim Grechushnikov, 2015-03-20
@maxyc_webber

blia, offtopic of course. but learn Russian, it's terribly unpleasant to read.
I think, having solved this question, the problem in the task will also disappear. An illiterate programmer didn't give up on anyone.
on the subject: in puff there are several functions for rounding. to more, to less, etc. use them
what is this footcloth of code supposed to do? perhaps this shit code can be wrapped after learning about the existence of public and private keys, uniqid, etc.
p.s. did not try to hurt religious feelings. nothing personal.

A
Artur Nurullin, 2015-05-15
@Splo1ter

Dude lit up =) - www.govnokod.ru/php?page=392

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question