php - How to generate same random string from two numbers even if we swap them? -
i looking following logic in php:
- first number 491
- second number 784
goal generate common encrypted string these 2 numbers, if reverse them:
<?php function common_string_generator($num1, $num2) { return enc_string_generator($num1, $num2); } # first $room_one = common_string_generator(491, 784); # second $room_two = common_string_generator(784, 491); if($room_one===$room_two) { print "success"; } else { print "failure"; } ?> #am here: <?php ........ $n1 = md5($num1, $num2); $n2 = md5(num2, num1); ........ ?>
i not able fix order of both numbers got reverse since both numbers ids of users going private chat room.
the both ids unique, , encrypted string these unique, want unique encrypted string become id of chat room.
you arbitrarily decide use smaller number first parameter , larger 1 second:
function common_string_generator($num1, $num2) { $param1 = min($num1, num2); $param2 = max($num1, num2); return enc_string_generator($param1, $param2); }
Comments
Post a Comment