View Source

<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[{zone-template-instance:ZFPROP:Proposal Zone Template}

{zone-data:component-name}
Zend_Filter_Hash
{zone-data}

{zone-data:proposer-list}
[Justin Hendrickson|mailto:justin.hendrickson@gmail.com]
{zone-data}

{zone-data:liaison}
TBD
{zone-data}

{zone-data:revision}
1.0 - 26 August 2009: Initial Draft.
{zone-data}

{zone-data:overview}
Zend_Filter_Hash is an adapter driven filter class for hashing strings.
{zone-data}

{zone-data:references}
* [http://www.php.net/crc32]
* [http://www.php.net/crypt]
* [http://www.php.net/hash]
* [http://www.php.net/md5]
* [http://www.php.net/sha1]
* [http://en.wikipedia.org/wiki/Cryptographic_hash_function]
{zone-data}

{zone-data:requirements}
* This component *will* provide support for hashing strings.
* This component *will* provide multiple adapters.
{zone-data}

{zone-data:dependencies}
* Zend_Filter_Interface
* Zend_Filter_Exception
{zone-data}

{zone-data:operation}
Zend_Filter_Hash will give a Zend_Filter interface to various hash extensions. Additionally, the crypt adapter will provide facilities for salting strings and comparing crypt'ed strings.
{zone-data}

{zone-data:milestones}
* Milestone 1: Design notes will be published here. [DONE]
* Milestone 2: Pulished working prototype.
* Milestone 2: Working prototype checked into the incubator supporting use cases.
* Milestone 3: Unit tests exist, work, and are checked into SVN.
* Milestone 4: Initial documentation exists.
{zone-data}

{zone-data:class-list}
* Zend_Filter_Hash
* Zend_Filter_Hash_Exception
* Zend_Filter_Hash_Adapter_Interface
* Zend_Filter_Hash_Adapter_Php
* Zend_Filter_Hash_Adapter_Hash
* Zend_Filter_Hash_Adapter_Crypt
* Zend_Filter_Hash_Adapter_Crypt_SaltGenerator_Interface
* Zend_Filter_Hash_Adapter_Crypt_SaltGenerator_Abstract
* Zend_Filter_Hash_Adapter_Crypt_SaltGenerator_Bcrypt
* Zend_Filter_Hash_Adapter_Crypt_SaltGenerator_ExtendedDes
* Zend_Filter_Hash_Adapter_Crypt_SaltGenerator_Md5
* Zend_Filter_Hash_Adapter_Crypt_SaltGenerator_StandardDes
* Zend_Filter_Hash_Adapter_Crypt_SaltGenerator_Sha256
* Zend_Filter_Hash_Adapter_Crypt_SaltGenerator_Sha512
{zone-data}

{zone-data:use-cases}
||UC-01||
Crypt a password using the system default algorithm.
{code}
$password = "password";

$filter = new Zend_Filter_Hash(array(
"adapter" => "crypt"
));

$ctext = $filter->filter($password);

$filter = new Zend_Filter_Hash(array(
"adapter" => "crypt",
"salt" => $ctext
));

var_dump($filter->filter($password) == $ctext); // bool(true)
{code}

||UC-02||
Crypt a password using Bcrypt with a cost of 10 (direct loading of the salt generator).
{code}
$password = "password";

$salt = new Zend_Filter_Hash_Adapter_Crypt_SaltGenerator_Bcrypt(array(
"cost" => 10
));

$filter = new Zend_Filter_Hash(array(
"adapter" => "crypt",
"salt" => $salt
));

$ctext = $filter->filter($password);

$filter = new Zend_Filter_Hash(array(
"adapter" => "crypt",
"salt" => $ctext
));

var_dump($filter->filter($password) == $ctext); // bool(true)
{code}

||UC-03||
Crypt a password using Bcrypt with a cost of 10 (lazy loading of the salt generator).
{code}
$password = "password";

$filter = new Zend_Filter_Hash(array(
"adapter" => "crypt",
"salt" => array(
"algorithm" => "bcrypt",
"cost" => 9
)
));

$ctext = $filter->filter($password);

$filter = new Zend_Filter_Hash(array(
"adapter" => "crypt",
"salt" => $ctext
));

var_dump($filter->filter($password) == $ctext); // bool(true)
{code}

||UC-04||
Hash a string with the hash extensions sha512 algorithm.
{code}
$text = "password";

$filter = new Zend_Filter_Hash(array(
"adapter" => "hash",
"algorithm" => "sha512"
));

var_dump($filter->filter($text)); // string(128) "b109f3bbbc244eb82441917ed06d618b9008dd09b3befd1b5e07394c706a8bb980b1d7785e5976ec049b46df5f1326af5a2ea6d103fd07c95385ffab0cacbc86"
{code}

||UC-05||
Hash a string with the php md5 algorithm.
{code}
$text = "password";

$filter = new Zend_Filter_Hash(array(
"adapter" => "php",
"algorithm" => "md5"
));

var_dump($filter->filter($text)); // string(32) "5f4dcc3b5aa765d61d8327deb882cf99"
{code}
{zone-data}

{zone-data:skeletons}
{code}
class Zend_Filter_Hash implements Zend_Filter_Interface
{

public function __construct($options = null)
{
}

public function __call($name, $arguements)
{
}

public function filter($value)
{
}

public function getAdapter()
{
}

public function getPluginLoader()
{
}

public function setAdapter($adapter)
{
}

public function setConfig(Zend_Config $config)
{
}

public function setOptions(array $options)
{
}

public function setPluginLoader(Zend_Loader_PluginLoader $pluginLoader)
{
}

}

class Zend_Filter_Hash_Exception extends Zend_Filter_Exception
{
}

class Zend_Filter_Hash_Adapter_Interface implements Zend_Filter_Interface
{
}

class Zend_Filter_Hash_Adapter_Hash implements Zend_Filter_Hash_Adapter_Interface
{

public function __construct($options = null)
{
}

public function filter($value)
{
}

public function getEnableRawOutput()
{
}

public function getSupportedAlgorithms()
{
}

public function setAlgorithm($algorithm)
{
}

public function setEnableRawOutput($enableRawOutput)
{
}

public function setConfig(Zend_Config $config)
{
}

public function setOptions(array $options)
{
}

}

class Zend_Filter_Hash_Adapter_Php implements Zend_Filter_Hash_Adapter_Interface
{

public function __construct($options = null)
{
}

public function filter($value)
{
}

public function getSupportedAlgorithms()
{
}

public function setAlgorithm($algorithm)
{
}

public function setConfig(Zend_Config $config)
{
}

public function setOptions(array $options)
{
}

}

class Zend_Filter_Hash_Adapter_Crypt implements Zend_Filter_Hash_Adapter_Interface
{

public function __construct($options = null)
{
}

public function filter($key)
{
}

public function getPluginLoader()
{
}

public function getSalt()
{
}

public function setConfig(Zend_Config $config)
{
}

public function setOptions(array $options)
{
}

public function setPluginLoader(Zend_Loader_PluginLoader $loader)
{
}

public function setSalt($salt)
{
}

}

interface Zend_Filter_Hash_Adapter_Crypt_SaltGenerator_Interface
{

public function __construct($options = null)
{
}

public function buildSalt()
{
}

}
{code}
{zone-data}

{zone-template-instance}]]></ac:plain-text-body></ac:macro>