0

I have this project, which uses gmdate as salt for some data

md5($mykey. gmdate('U'));

I wanted to change this project's folder structure, and after moving a few files, now gmdate('U') always returns 1.

I cloned the original project again and gmdate('U') works fine. They are both in the same enviroment.

What's causing gmdate('U') to always return 1 whenever it's changed?

prgrm
  • 3,734
  • 14
  • 40
  • 80
  • You can solve this problem by using a better salt. This is deterministic and you can easily get collisions. Use something like [`openssl_random_pseudo_bytes()`](http://php.net/manual/en/function.openssl-random-pseudo-bytes.php) to generate better salts. See https://stackoverflow.com/a/2088983/250259 – John Conde Feb 11 '19 at 21:41
  • @JohnConde Sadly I don't have any choice. It's not an important hash either. – prgrm Feb 11 '19 at 21:48
  • @prgrm Try to use [microtime()](http://php.net/manual/en/function.gmdate.php) instead of ```gmdate('U')```. Or [uniqid](http://php.net/manual/en/function.uniqid.php), it also based on time in microseconds. – Sergey Poltaranin Feb 12 '19 at 04:47

0 Answers0