Advertisement
Guest User

Untitled

a guest
Feb 27th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. private function generateReferenceNumber($prefix = null, $length = 8)
  2. {
  3. $az = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZMULTIPAY';
  4. $azr = rand(0, 51);
  5. $azs = substr($az, $azr, 10);
  6. $stamp = hash('sha256', time());
  7. $mt = hash('sha256', mt_rand(5, 20));
  8. $alpha = hash('sha256', $azs);
  9. $hash = str_shuffle($stamp . $mt . $alpha);
  10. $code = strtoupper(substr($hash, $azr, $length));
  11.  
  12. if (!is_null($prefix) && !empty(trim($prefix))) {
  13. $code = $prefix . $code;
  14. }
  15.  
  16. return $code;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement