简体   繁体   中英

C# sha256 into PHP

I've got a table of hashes and salts previously created by by another company. The hash was done in C# and the hash method is sha256. The logic behind this is sha256(password+salt) .

An example of inputs:

password = 'rosnicka'
salt     = 'zxwqTy+XjaY=' 
hash     = '3jdt1+JL3MPmjYr2OoXdoUwNfuweuDCZa8/3g7SfsNg='

When I tried to run a hashing function in PHP

the output of this is "1125ed47a7aa11bc1c54c841b5eb7a6e72aa8ad27e010e6e25baa5b2a86cffb3"

I get the same results using only hashing calculators

I contacted them to find out what I'm doing wrong. They told me, that are storing ASCII version of the hash in the database. What should I do in order to get the same hash in PHP or what to do in order to convert their hash to the original sha256 hash?

thanks a lot!

As alex K said:

base64_encode(hash('sha256', 'rosnicka'.base64_decode('zxwqTy+XjaY='), true));

will do the trick

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM