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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.