Bitcoin Forum

Economy => Gambling => Topic started by: leex1528 on May 19, 2014, 01:43:56 PM



Title: php hash function
Post by: leex1528 on May 19, 2014, 01:43:56 PM
So I have tried asking around at the gambling sites what

hash('sha512, $var1, $var2, $var3) returns.

No one has been able to give me an answer, yet they were all convinced they knew what it meant.


I am curious what value that returns.  Yes I understand it is the hash sha 512 value, I am more asking how does it calculate that

Does it randomize the 3 variables and return them as a 512 bit string in a completely random order?  Does it truncate certain variables and then randomize them?

Any thoughts on this anyone?

Thanks!


Title: Re: php hash function
Post by: Bitsky on May 20, 2014, 07:25:12 AM
So I have tried asking around at the gambling sites what

hash('sha512, $var1, $var2, $var3) returns.
First, you're missing a '.

Anyway, according to the docs this won't return anything but an error:

Code:
<?php
$var1 
$var2 $var3 1;
$hash hash('sha512'$var1$var2$var3);
var_dump($hash);
?>

Code:
Warning: hash() expects at most 3 parameters, 4 given in test.php on line 3
NULL


Title: Re: php hash function
Post by: leex1528 on May 20, 2014, 12:45:11 PM
So I have tried asking around at the gambling sites what

hash('sha512, $var1, $var2, $var3) returns.
First, you're missing a '.

Anyway, according to the docs this won't return anything but an error:

Code:
<?php
$var1 
$var2 $var3 1;
$hash hash('sha512'$var1$var2$var3);
var_dump($hash);
?>

Code:
Warning: hash() expects at most 3 parameters, 4 given in test.php on line 3
NULL

Sorry for the typo.

Errr, I am not asking what that code really does that I wrote, just a in general question.  I am trying to learn about the hash function, I did find some good information on it though


Title: Re: php hash function
Post by: FastSlots on May 20, 2014, 01:13:56 PM
There are several different hash functions such as sha, md5, or haval. They can be applied to a string and return another string called a digest. Hash functions have some interesting properties:

* it is easy to compute the digest for any given string
* it is infeasible to generate a string that has a given digest
* it is infeasible to modify a string without changing the digest
* it is infeasible to find two different strings with the same digest.

You can learn more about hash functions on wikipedia (http://en.wikipedia.org/wiki/Cryptographic_hash_function)

The php function 'hash' takes two inputs, a hash algorithm such as sha256 and a string to be hashed. For example 'hash("sha256", $str)' will return the sha256-hash of the string $str. I guess what you are looking for is the hash of the concatenation of $var1, $var2, $var3. Try 'hash("sha256", $var1.$var2.$var3)'.


Title: Re: php hash function
Post by: leex1528 on May 20, 2014, 01:31:46 PM
Thanks for the info!  I will keep researching and try to get a better understanding!