1

I hashing my password using below method in PHP

$password=hash('sha256','123');

Now i want to decode it, how it is possible? I doesn't use any key or salt.

<?php
$password=hash('sha256','123');
echo $password;
$decdoe=base64_decode($password);
echo $decdoe;
?>
brombeer
  • 8,716
  • 5
  • 21
  • 27
Spieder Man
  • 29
  • 1
  • 6
  • 3
    Hashing is not the same as encrypting, it isn't reversible. Also: `base64_decode` doesn't have anything to do with encrypting / decrypting or sha256 at all, it's decoding - not decrypting. – ccKep Jan 12 '19 at 07:24
  • 2
    Have a look at [How to use password_hash](https://stackoverflow.com/questions/30279321/how-to-use-password-hash) instead. – Nigel Ren Jan 12 '19 at 07:26
  • 1
    read this post on SO, i think it can help you: [code and decode](https://stackoverflow.com/questions/1289061/best-way-to-use-php-to-encrypt-and-decrypt-passwords) – Ferdinando Jan 12 '19 at 08:11
  • check this three website can decrypt so its possible https://md5decrypt.net/en/Sha256/ https://www.dcode.fr/sha256-hash http://hashtoolkit.com/reverse-hash?hash=a665a45920422f9d417e4867efdc4fb8a04a1f3fff1fa07e998e86f7f7a27ae3 – Spieder Man Jan 12 '19 at 11:03
  • @SpiederMan "decrypt" or "dehashing" a hash is not possible. These websites only have a database of "msg <-> hash" pairs they check against. If they don't have such a pair in their database they can't give you the original message/string before the hashing. – Progman Jan 12 '19 at 13:03

1 Answers1

2

base64_decoding means decrypting a file using base64 algorithm. This is called encrypting. Hashing is a different case. when hashing what you hash cannot be recreated. so the purpose of hashing is to check the integrity of a file in this case the password. that means if u hash a password at the registration u will save the hashed part in the password field as password. Now when you re check it you need to check by hashing the user input password again with the value in your database. So using this code below

$hashed_password = password_hash($password, PASSWORD_DEFAULT);
// hash a password and store it into database

if(password_verify($password, $hashed_password)){ // here $password means user input when loggin $hashed_password is the hash from the database relevant to trying loggin 

}else{
 //throw error msg
}
ALPHA
  • 1,135
  • 1
  • 8
  • 18
  • this three website can decrypt so its possible https://md5decrypt.net/en/Sha256/ https://www.dcode.fr/sha256-hash http://hashtoolkit.com/reverse-hash?hash=a665a45920422f9d417e4867efdc4fb8a04a1f3fff1fa07e998e86f7f7a27ae3 – Spieder Man Jan 12 '19 at 10:58
  • i don't want any security on password, just encode and decode using shat256 – Spieder Man Jan 12 '19 at 11:05
  • no need to decode is what i'm saying you just need to use those 2 functions i have provided – ALPHA Jan 12 '19 at 13:09
  • i don't wont to verify i just convent "a665a45920422f9d417e4867efdc4fb8a04a1f3fff1fa07e998e86f7f7a27ae3" using sha256. Now i want to back simple in "123" format. how this is possible. forget about password. i just want to covert string to using sha256 now i want it to normal – Spieder Man Jan 15 '19 at 12:26
  • that's a different question ask it again then as a new one – ALPHA Jan 15 '19 at 12:29
  • I clearly understand what my question is . i also find that some of question related to this are not properly answered, That's why i used that word encode and i clearly specify that "I doesn't use any key or salt" so that some people cant confuse. – Spieder Man Jan 18 '19 at 12:54
  • may be try reading what people have answered your question can benefit you greatly.... try doing that may be and try to be more polite yeah ? and please for the last time read this - http://php.net/manual/en/function.hash.php – ALPHA Jan 18 '19 at 13:12
  • can you add an email or a fb profile that I can get in touch with you .. I will solve your problem .. – ALPHA Jan 18 '19 at 13:17
  • i think its not possible in php, the website who decode or unhash string using their dictionary – Spieder Man Jan 19 '19 at 06:52