Encrypt Numbers To Another Number

encrypt numbers to another number

Encrypt Numbers To Another Number

 |   |  0

There are lot of number starting from zero to n. We don’t wanna show this ordered id to anyone and we have to give unique number somewhere. How to encrypt numbers to another number?

So how to encode number to another number by simple method? And each encoded number just represent just one number. Just like encryption not hashing. We also need uniqueness means if 56 give 842 then no else should give 842.

I will try to explain how to make a function for it.


$order_id = 456;
$a = $order_id * $order_id * $order_id;
$secure = rand(100,999).$a.rand(100,999);


$secure = SOME_NO ;
$unsecure = substr($secure,3);
$order_id = pow(substr($unsecure, 0, -3), 1/3);
$order_id = ceil($order_id);

$order_id contains decrypted number. It is not much heavy and very simple.

0 Claps

Show your love in the form of Claps and Comments...


No comments found. Leave your reply here.