SHA256 version 2.0 alpha 3 - updated

Coding Critique is the place to post source code for peer review by other members of DevNetwork. Any kind of code can be posted. Code posted does not have to be limited to PHP. All members are invited to contribute constructive criticism with the goal of improving the code. Posted code should include some background information about it and what areas you specifically would like help with.

Popular code excerpts may be moved to "Code Snippets" by the moderators.

Moderator: General Moderators

User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

What's the error? You could easily be using the class incorrectly.
KalleL
Forum Newbie
Posts: 12
Joined: Mon Apr 30, 2007 8:52 am

Post by KalleL »

Okay, error is:

Parse error: parse error, unexpected T_ARRAY, expecting '&' or T_VARIABLE in /path/to/testfolder/Sha256.class.php on line 262

And the small sample code i'm using is:

Code: Select all

<?php

include 'hash_sha256.php';

$sha256 = new Sha256v2();
$hash1 = $sha256->hash(new StringInput('hashi1'));

echo 'hashi1 - '.$hash1;

?>
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

Try including Sha256.class.php instead of hash_sha256.php.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

If memory serves, the array type hint was added in 5.1. I'll make a note to take that bit out in the next test release.

Also, as a reminder to everyone using the existing test builds, since this is an Alpha level release, the interface isn't 100% solid. I am mulling over a few changes that will alter the interface of the classes some. If possible, I will maintain compatibility with the existing interface, but some of the changes may just not hold. Sorry for any inconvenience that may cause anyone.

Hopefully with summer school wrapping up in a few weeks, I'll get some time to bang out a few more alphas, hopefully go into beta.
KalleL
Forum Newbie
Posts: 12
Joined: Mon Apr 30, 2007 8:52 am

Post by KalleL »

superdezign wrote:Try including Sha256.class.php instead of hash_sha256.php.
Tried it too.
User avatar
feinstimmer
Forum Newbie
Posts: 19
Joined: Thu Dec 07, 2006 8:36 am

Number of characters

Post by feinstimmer »

Stuped qestion: how manu characters sha256 returns when hashing string(password)?
Thanks.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Re: Number of characters

Post by feyd »

feinstimmer wrote:Stuped qestion: how manu characters sha256 returns when hashing string(password)?
Thanks.
A simple test on your behalf would have told you. ;)

It returns a 256bit result. In hex that's 64 bytes.
Post Reply