Bitcoin Forum
May 29, 2024, 12:47:45 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: php hash function  (Read 493 times)
leex1528 (OP)
Hero Member
*****
Offline Offline

Activity: 784
Merit: 1000


View Profile
May 19, 2014, 01:43:56 PM
 #1

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!
Bitsky
Hero Member
*****
Offline Offline

Activity: 576
Merit: 514


View Profile
May 20, 2014, 07:25:12 AM
 #2

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

Bounty: Earn up to 68.7 BTC
Like my post? Feel free to drop a tip to 1BitskyZbfR4irjyXDaGAM2wYKQknwX36Y
leex1528 (OP)
Hero Member
*****
Offline Offline

Activity: 784
Merit: 1000


View Profile
May 20, 2014, 12:45:11 PM
 #3

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
FastSlots
Hero Member
*****
Offline Offline

Activity: 1008
Merit: 500



View Profile
May 20, 2014, 01:13:56 PM
 #4

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)'.
leex1528 (OP)
Hero Member
*****
Offline Offline

Activity: 784
Merit: 1000


View Profile
May 20, 2014, 01:31:46 PM
 #5

Thanks for the info!  I will keep researching and try to get a better understanding!
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!