1
I made a page that shows the hash in several hash_algos in order to study their differences, but I would like to sort by the hash size and not by the hash_algos name, the code is this,
<?php foreach (hash_algos() as $hash_algos) {
$hash = hash($hash_algos, "salt", false); ?>
<li>
<span><?php echo $hash_algos; ?></span>
<span><?php echo strlen($hash); ?></span>
<span><?php echo $hash; ?></span>
</li>
<?php } ?>
would be like when printing, be ordered by the size of the hash that in the case depending on the algos it will have from 8 until 128 and make a sub Sort with the algos, ie put all of 8 with all fnv, the second Sort is not so important, I just really wanted to see how to sort out what size indicates.
example in ideone
Grateful from now on
perfect, very cool, I saw in many places I needed to create another Function but I was not understanding how to do, this PHP_EOL at the end serves for what same?
– flourigh
correct if you are wrong, it is to make the line break?
– flourigh
@flourigh is just to break the lines in the demo (equivalent to " n" or " r n" of the operating system, in your case just hit the HTML). The important thing is to understand the function
usort– Bacco
yes, it inside the function will see who is bigger and put it in the queue up or down to compare with the next, I had no interaction with it even before you show me, very good.
– flourigh