Why a flip a bin before hashing in this script?

2

From How can I make this PHP merkle root script recursive?

function binFlipByteOrder($string) {
    return implode('', array_reverse(str_split($string, 1)));
}

Why a flip?

Nicolas Cantu

Posted 2018-11-26T15:08:57.920

Reputation: 23

Answers

3

Hashes are big endian by standard, and most computers use little endian, so it's probably just for convenience. See Why does the Bitcoin protocol use the little-endian notation?

JBaczuk

Posted 2018-11-26T15:08:57.920

Reputation: 6 172

Ok thanks you! (I suspected the Lilliputians..)Nicolas Cantu 2018-11-26T15:37:08.667

haha they are alive and well in Bitcoin... :)JBaczuk 2018-11-26T15:37:48.683

Of course it's a little big part of Internet (Cohen) and a community story :) So they are well in Bitcoin :)Nicolas Cantu 2018-11-27T00:26:28.093