Guest User

Untitled

a guest
May 25th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. <?php
  2.  
  3. /*
  4. |--------------------------------------------------------------------------
  5. | 安全随机字符串
  6. |--------------------------------------------------------------------------
  7. |
  8. | 安全随机安字符串函数使用。
  9. |
  10. */
  11.  
  12. echo bin2hex(openssl_random_pseudo_bytes(128));
  13.  
  14. // 拓展生成订单号
  15. function generateOrderId($lenght = 13)
  16. {
  17. return date('ymd') . bin2hex(openssl_random_pseudo_bytes(ceil($lenght / 2))) . str_pad(rand(1, 9999), 5, 0, STR_PAD_LEFT);
  18. }
  19.  
  20. echo generateOrderId();
Add Comment
Please, Sign In to add comment