Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.
  • Root
  • » PHP
  • » [PHP-DEV] sha256(), sha256_file(), and other hashing algos [RSS Feed]

#1 Nov. 18, 2005 16:41:33

Sara G.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[PHP-DEV] sha256(), sha256_file(), and other hashing algos


Following an offline discussion with some internals folks, I've put togethera general hashing extensions which could potentially find a place in core asan enabled by default extension:ext/hash:

string hash(string $algo, string $value)
string hash_file(string $algo, string $filename)Where $algo is (currently) any of 'md5', 'sha1', 'sha256', 'sha384','sha512', 'ripemd128', 'ripemd160' each of which are implemented internallyusing raw math and no library dependencies. I've also got an upgrade pathlaid out for extracting md5() and sha1() from core in future versions (6.0?)without compromising backward compatability.The extension also supports incremental hashing:

resource hash_init($algo);
bool hash_update($context, $data);
string hash_final($context)External extensions can already "register" additional hashing algos usingthe module dependency hooks now available.For the future I've got plans for allowing registration of userspace hashingfunctions, HMAC support, and a streams filter implementation as well asadditional engines: crc, haval, md4, etc...Examples:

$digest = hash('sha256', 'abc');

$ctx = hash_init('sha256');
hash_update($ctx, 'a');
hash_update($ctx, 'bc');
$digest = hash_final($ctx);I'm just putting on some finishing touches and will post a tarball latertoday.-Sara--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit:http://www.php.net/unsub.php

Offline

#2 Nov. 19, 2005 15:13:26

Markus F.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[PHP-DEV] sha256(), sha256_file(), and other hashing algos


Hi,I'm missing the functionality to get a list of registered hash functionsso one can probe whether a certain hash function is available or not.- Markus

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

Offline

#3 Nov. 19, 2005 20:33:35

Sara G.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[PHP-DEV] sha256(), sha256_file(), and other hashing algos


I'm missing the functionality to get a list of registered hash functionsso one can probe whether a certain hash function is available or not.There is now :)

array hash_algos(void)
Returns numerically indexed array of hashing engine names.And just incase anyone missed it. The proto for hash_init() has beenextended:resource hash_init(string algo)

Options currently has one possible value: HASH_HMAC
When specified, key must be specified as well (to be used for the HMAC key).

HMAC can be used with any of the hashing algos included in ext/hash.Examples of using HMAC with official test vectors can be found intests/hmac-md5.phptI'd rather not complicate the proto for the core hash() function with HMACand other options, but maybe a separate hash_hmac() and/or hash_hmac_file()might be in order?-Sara--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit:http://www.php.net/unsub.php

Offline

  • Root
  • » PHP
  • » [PHP-DEV] sha256(), sha256_file(), and other hashing algos [RSS Feed]

Board footer

Moderator control

Enjoy the 18th of November
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support