doubledee Posted June 8, 2012 Share Posted June 8, 2012 What does sha1() return if it fails? I thought it was FALSE, but can't find that in the Manual... Debbie Quote Link to comment https://forums.phpfreaks.com/topic/263843-what-if-sha1-fails/ Share on other sites More sharing options...
scootstah Posted June 8, 2012 Share Posted June 8, 2012 Why would it fail? Quote Link to comment https://forums.phpfreaks.com/topic/263843-what-if-sha1-fails/#findComment-1352052 Share on other sites More sharing options...
doubledee Posted June 8, 2012 Author Share Posted June 8, 2012 Why would it fail? That's not the question. The questions is "When it does fail, what is returned?" so I know how to Error-Handle it! Debbie Quote Link to comment https://forums.phpfreaks.com/topic/263843-what-if-sha1-fails/#findComment-1352054 Share on other sites More sharing options...
doubledee Posted June 8, 2012 Author Share Posted June 8, 2012 Currently I have this code, but I'm not sure if its valid... // ************************** // Create New Image Name. * // ************************** $newBasename = sha1_file($tempFile); if (!$newBasename){ // Hashing Failed. $_SESSION['resultsCode'] = 'UPLOAD_HASH_IMAGE_FAILED_2119'; // Set Error Source. $_SESSION['errorPage'] = $_SERVER['SCRIPT_NAME']; // Save Session Data. session_write_close(); // Redirect to Outcome Page. header("Location: " . BASE_URL . "/account/results.php"); // End script. exit(); } Debbie Quote Link to comment https://forums.phpfreaks.com/topic/263843-what-if-sha1-fails/#findComment-1352055 Share on other sites More sharing options...
scootstah Posted June 8, 2012 Share Posted June 8, 2012 So to be clear, we are talking about sha1_file() and not sha1()? The only way I can think sha1_file() would return false is if the file does not exist. As you'll notice, sha1() doesn't return false on failure because it can't fail. Quote Link to comment https://forums.phpfreaks.com/topic/263843-what-if-sha1-fails/#findComment-1352056 Share on other sites More sharing options...
doubledee Posted June 8, 2012 Author Share Posted June 8, 2012 So to be clear, we are talking about sha1_file() and not sha1()? My bad. No, I mean sha1() since I am using that per my earlier thread on getting a unique Photo Name... The only way I can think sha1_file() would return false is if the file does not exist. As you'll notice, sha1() doesn't return false on failure because it can't fail. Dying last words... Okay, so if I don't need to worry about sha1() failing, then I can remove that Error-Handling Code, which is good, because I can use that Error # for a new Error-Check I need to do! Thanks, Debbie Quote Link to comment https://forums.phpfreaks.com/topic/263843-what-if-sha1-fails/#findComment-1352060 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.