Jump to content

What if SHA1 Fails?


doubledee

Recommended Posts

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

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/263843-what-if-sha1-fails/#findComment-1352055
Share on other sites

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

 

Link to comment
https://forums.phpfreaks.com/topic/263843-what-if-sha1-fails/#findComment-1352060
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.