Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:20166 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 79821 invoked by uid 1010); 18 Nov 2005 16:41:00 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 79806 invoked from network); 18 Nov 2005 16:41:00 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Nov 2005 16:41:00 -0000 X-Host-Fingerprint: 69.12.155.130 69-12-155-130.dsl.static.sonic.net Linux 2.4/2.6 Received: from ([69.12.155.130:1742] helo=pigeon.alphaweb.net) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id 47/20-07637-B140E734 for ; Fri, 18 Nov 2005 11:41:00 -0500 Received: from localhost ([127.0.0.1] helo=stumpy) by pigeon.alphaweb.net with smtp (Exim 4.10) id 1Ed8W6-0004Sm-00 for internals@lists.php.net; Fri, 18 Nov 2005 07:51:10 -0800 Message-ID: <000701c5ec5f$33e2ff90$7d051fac@stumpy> To: Date: Fri, 18 Nov 2005 08:43:28 -0800 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.2180 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 Subject: sha256(), sha256_file(), and other hashing algos From: pollita@php.net ("Sara Golemon") Following an offline discussion with some internals folks, I've put together a general hashing extensions which could potentially find a place in core as an enabled by default extension: ext/hash: string hash(string $algo, string $value[,$raw=false]) string hash_file(string $algo, string $filename[,$raw=false]) Where $algo is (currently) any of 'md5', 'sha1', 'sha256', 'sha384', 'sha512', 'ripemd128', 'ripemd160' each of which are implemented internally using raw math and no library dependencies. I've also got an upgrade path laid 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[,$raw=false]) External extensions can already "register" additional hashing algos using the module dependency hooks now available. For the future I've got plans for allowing registration of userspace hashing functions, HMAC support, and a streams filter implementation as well as additional 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 later today. -Sara