Jump to content

How secure is this?


waynewex

Recommended Posts

Anyone who is a bit more knowledgeable on password hasing; please give me feedback on how secure this is. Thanks.

 

<?php

function pass_hash($original){
    
     $pass = sha1($original);
     $pass = sha1("hsyens!".$pass."jhjs23!jh");
     $pass = $pass.$pass;
     $pass = sha1($pass);

     return $pass;

}

?> 

 

 

Link to comment
Share on other sites

yea i think that looks robust but remember sha1 is unreversable so if you are going to try crack it you would properly try a brute force attack so adding

     $pass = sha1("hsyens!".$pass."jhjs23!jh");
     $pass = $pass.$pass;
     $pass = sha1($pass);

might end up with the same hash as "a" or the same has as "asdasd" just adding some random stuff like "jhjs23" to the original password should secure it providing your source is secure and no one else is going to find out your method

 

Scott.

Link to comment
Share on other sites

It depends on how you are using this.

Are you encrypting passwords to store in a database? If you are using a form to authenticate users i.e. username and password then taking the password value, running it through your function and comparing it to a database value to authenticate then there is still an element of insecurity. Because POST requests are made in name=>value pairs in clear text the password that a user types in can be intercepted before it gets to the server via a packet sniffer. The most secure way is to encrypt the password on the client side before it is sent to the server.

 

Take a look at http://pajhome.org.uk/crypt/md5/

 

This uses MD5 encryption

Link to comment
Share on other sites

I was thinking that. Also:

 

Over the web, JS cryptography can only protect against passive eavesdropping, as the JavaScript itself is downloaded over an insecure link. If an attacker can modify network traffic, they can make malicious changes to the JavaScript code.

 

In any case, JS interpreters are not designed for secure programming. They may leave sensitive information lying about in memory. They're too slow for some algorithms, e.g. BSD-style MD5 passwords, or RSA with full-size keys. Bitwise operations are buggy in several implementations.

 

I suppose that it can help though. No JS would be a major problem.

Link to comment
Share on other sites

If a user has javascript turned off then the value will not be encrypted and then never match up to any encrypted stored password anyway so they would never be able to authenticate. You can also detect this behaviour in your application anyway using <noscript> tags

Link to comment
Share on other sites

If it is the case that this is for website authentication and you are not confident that the above would help then purchase and install an SSL certificate. Users passwords can still go through your function and marry up to database stored versions.

Link to comment
Share on other sites

Btw, it's for an admin login section. I'm expecting the login section to come under some slight pressure from others if you know what I mean. Although the folders are protected with index.php redirects back to the homepage, I'm still a bit iffy about it all.

Link to comment
Share on other sites

This depends on the type of certificate. Obviously the most expensive offer the highest protection and are probably way beyond your needs. Go to godaddy.com or someone similar. UK price is about £40 for a cert and we use to protect payment details, etc on websites without any issue.

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.