Am 01.04.2017 um 05:12 schrieb Yasuo Ohgaki <yohg...@ohgaki.net>:
> I noticed that our SHA-3 is inefficient.
> 
> === Ruby SHA3-256 ===
> [yohgaki@dev ~]$ cat t2.rb
> #!/usr/bin/env ruby
> 
> require 'digest/sha2'
> 
> $i = 1000000
> until $i do
>       Digest::SHA3.hexdigest("abcdedf", 256)
>       $i -= 1
> end

Two things I noticed:
1) As far as I understand Ruby (and as far as I tested it) this does not 
execute the function at all. You probably mean something like
        while $i > 0 do

2) For some reason the Ruby implementation yields different results, I didn't 
track down why.
        - hash("sha3-256", "abc"); =>  
3a985da74fe225b2045c172d6bd390bd855f086e3e9d525b46bfe24511431532
          which matches the test vector at 
http://www.di-mgt.com.au/sha_testvectors.html
        - Digest::SHA3.hexdigest("abc", 256) => 
4e03657aea45a94fc7d47ba826c8d667c0d1e6e33a64a036ec44f58fa12d6c45

For whatever reason this is, it means that you can't really compare those two 
functions.

Regards,
- Chris


--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to