FAQ
Edit report at https://pear.php.net/bugs/bug.php?id=15346&edit=1

ID: 15346
Updated by: mike@silverorange.com
Reported By: mike at silverorange dot com
Summary: Create more specific exception for hash algorithm not
found or return a boolean
Status: Open
Type: Feature/Change Request
Package: Crypt_HMAC2
Operating System: Irrelevant
Package Version: 0.2.1
PHP Version: Irrelevant
Roadmap Versions:
New Comment:

Any progress on this feature request? The patch should be pretty
straightforward.


Previous Comments:
------------------------------------------------------------------------

[2009-06-19 06:59:46] gauthierm

Poke poke. Patch is still attached.

------------------------------------------------------------------------

[2008-12-27 20:52:43] gauthierm

Option 2 makes the most sense to me as well, and would fit with the way
I'm currently using Crypt_HMAC2.

Here's what I have currently:

try {
// try first to use SHA-256
$hmac = new Crypt_HMAC2($secretKey, 'SHA256');
} catch (Crypt_HMAC2_Exception $e) {
// if SHA-256 is not available, use SHA-1
$hmac = new Crypt_HMAC2($secretKey, 'SHA1');
}

------------------------------------------------------------------------

[2008-12-26 23:31:38] doconnor

I like option 2 best

------------------------------------------------------------------------

[2008-12-18 09:47:43] gauthierm

Description:
------------
I'd like to write code that uses SHA-256 if available and otherwise uses
SHA-1. The way the setHash() method works this is a bit cumbersome. I
can think of three ways to make it better:

1.) Create a hasHashAlgorithm() method I can use to check for SHA_256
2.) Throw a more specific exception in setHashAlgorithm() like
Crypt_HMAC2_InvalidAlgorithmException
3.) Return a boolean from setHashAlgorithm(). True on success and false
on failure.

------------------------------------------------------------------------

Search Discussions

  • Daniel Oconnor at Jan 24, 2012 at 12:33 pm
    Edit report at https://pear.php.net/bugs/bug.php?id=15346&edit=1

    ID: 15346
    Updated by: daniel.oconnor@gmail.com
    Reported By: mike at silverorange dot com
    Summary: Create more specific exception for hash algorithm not
    found or return a boolean
    -Status: Open
    +Status: Closed
    Type: Feature/Change Request
    Package: Crypt_HMAC2
    Operating System: Irrelevant
    Package Version: 0.2.1
    PHP Version: Irrelevant
    -Assigned To:
    +Assigned To: doconnor
    Roadmap Versions:
    New Comment:

    -Status: Open
    +Status: Closed
    -Assigned To:
    +Assigned To: doconnor
    This bug has been fixed in SVN.

    If this was a documentation problem, the fix will appear on pear.php.net
    by the end of next Sunday (CET).

    If this was a problem with the pear.php.net website, the change should
    be live shortly.

    Otherwise, the fix will appear in the package's next release.

    Thank you for the report and for helping us make PEAR better.




    Previous Comments:
    ------------------------------------------------------------------------

    [2012-01-04 03:34:09] gauthierm

    Any progress on this feature request? The patch should be pretty
    straightforward.

    ------------------------------------------------------------------------

    [2009-06-19 06:59:46] gauthierm

    Poke poke. Patch is still attached.

    ------------------------------------------------------------------------

    [2008-12-27 20:52:43] gauthierm

    Option 2 makes the most sense to me as well, and would fit with the way
    I'm currently using Crypt_HMAC2.

    Here's what I have currently:

    try {
    // try first to use SHA-256
    $hmac = new Crypt_HMAC2($secretKey, 'SHA256');
    } catch (Crypt_HMAC2_Exception $e) {
    // if SHA-256 is not available, use SHA-1
    $hmac = new Crypt_HMAC2($secretKey, 'SHA1');
    }

    ------------------------------------------------------------------------

    [2008-12-26 23:31:38] doconnor

    I like option 2 best

    ------------------------------------------------------------------------

    [2008-12-18 09:47:43] gauthierm

    Description:
    ------------
    I'd like to write code that uses SHA-256 if available and otherwise uses
    SHA-1. The way the setHash() method works this is a bit cumbersome. I
    can think of three ways to make it better:

    1.) Create a hasHashAlgorithm() method I can use to check for SHA_256
    2.) Throw a more specific exception in setHashAlgorithm() like
    Crypt_HMAC2_InvalidAlgorithmException
    3.) Return a boolean from setHashAlgorithm(). True on success and false
    on failure.

    ------------------------------------------------------------------------

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppear-bugs @
categoriesphp
postedJan 4, '12 at 2:33a
activeJan 24, '12 at 12:33p
posts2
users2
websitepear.php.net

2 users in discussion

Daniel Oconnor: 1 post Mike: 1 post

People

Translate

site design / logo © 2022 Grokbase