note 124596 added to function.md5

From: Date: Fri, 10 Jan 2020 02:20:03 +0000
Subject: note 124596 added to function.md5
Groups: php.notes 
Request: Send a blank email to php-notes+get-213836@lists.php.net to get a copy of this message
I've found multiple sites suggesting the code: md5(file_get_contents($filename)); Until recently, I hadn't noticed any issues with this locally... but then I tried to hash a 700MB file, with a 2048MB memory limit and kept getting out of memory errors... There appears to be a limit to how long a string the md5() function can handle, and the alternative function is likely more memory efficient anyway. I would highly recommend to all who need file hashing (for detecting duplicates, not security digests) use the md5_file() function and NOT the regular string md5() function! md5_file($filename); Note, to those interested, as this was for a local application not a server, I was more concerned with results than memory efficiency. In a live environment, you would never want to read an entire file into memory at once when avoidable. (at the time of coding, I did not know of the alternative function) ---- Server IP: 45.112.84.4 Probable Submitter: 38.142.137.34 (proxied: 199.115.135.254) ---- Manual Page -- http://php.net/manual/en/function.md5.php Edit -- https://master.php.net/note/edit/124596 Del: integrated -- https://master.php.net/note/delete/124596/integrated Del: useless -- https://master.php.net/note/delete/124596/useless Del: bad code -- https://master.php.net/note/delete/124596/bad+code Del: spam -- https://master.php.net/note/delete/124596/spam Del: non-english -- https://master.php.net/note/delete/124596/non-english Del: in docs -- https://master.php.net/note/delete/124596/in+docs Del: other reasons-- https://master.php.net/note/delete/124596 Reject -- https://master.php.net/note/reject/124596 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#213836) next »