$clear_text = "hello";
$salt_ = sha1("758hF4H7gJi98U6o");
$salt = substr($salt_, 0, 12);
$hash = substr(hash("sha512", $clear_text), 0, 20).$salt;
As you can see, $hash
generates a 32 character string, making it look identical to md5. So a hacker will be trying to decrpyt this md5 hash when in fact it is nothing like that! Would this be cunning, and would it be a good idea?
Don't try to invent your own crypto, use standardized hashing algorithms like bcrypt, scrypt or PBKDF2.
Please refer to:
There is a principle in security which is called Kirckhoff's principle, one of the rules is "It must not be required to be secret, and it must be able to fall into the hands of the enemy without inconvenience" Suggest the attacker has access to your machine and is able to dump your source files as well as your database it won't take him very long to discover your algorithm.
Now from there your own rolled algorithm doesn't really provide any additional protection from normal sha512+salt. The speed at which he would be able to attack the hashes would be the same with or without your algorithm. Meaning your scheme is useless once the algorithm as been found.
$salt_ = sha1("758hF4H7gJi98U6o");
Hashing entropy does not provide better entropy. See What should be used as a salt?. Summary: encode a unique and unpredictable value.
$hash = substr(hash("sha512", $clear_text), 0, 20).$salt;
You should use multiple iterations of hashing. See How to securely hash passwords. Summary: PBKDF2, BCrypt, SCrypt provide this.
Would this be cunning
No, and it'd be essentially irrelevant if your code was read as well.
and would it be a good idea
It'd more likely be a nuisance for anybody who ever had to maintain it in the future. It's probably not a bad idea on the face of it in that altering the hash format may confuse somebody, but you can consider that in-hand with reading The valid role of obscurity. If you're going to alter the hash format, spend that effort to encrypt it so it can't be attacked without the encryption key. The effort to find the key would probably be the same, but it'd be a much easier decision to defend.