Re: Crypt package
| From: | Michael Bretterklieber | Date: | Sun, 16 Feb 2003 08:33:00 +0000 |
| Subject: | Re: Crypt package | ||
| References: | 1 2 3 4 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-13354@lists.php.net to get a copy of this message | ||
Hi,
Christian Dickmann schrieb:
at the moment Tim Thorpe <blushift@netins.net> is implementing a protype based on his DES-Classes. At the moment there is no api-specification, but will be available soon. For asymmetric ciphers we have to make it a bit different maybe a sublass of the base-crypt class: Crypt Crypt_Symmetric Crypt_Asymmetric because there have to be more methods like "seal" and "sign" for RSA. and maybe Crypt_Digest The RSA implementation should then go to the Ciphers-subdir: Crypt/Ciphers/RSA.php ... or are there any other (better) suggestions? Here's what I mailed to Tim:I send the proposal of another idea to Tim, to make the Crypt package similar to the Auth package, but instead of Containers we will haveCiphers. I want to participate! ;) Wanted to release Crypt_RSA this week ... but now I will wait a moment and adjust it to the new base class. Maybe a talk about the new api would be good to match all needs.
now I had another idea how such package can be implemented. The Auth package has an Auth class and has Containers. We can do it similar: Crypt Crypt/Ciphers Crypt/Ciphers/DES Crypt/Ciphers/3DES Crypt/Ciphers/Blowfish
The Crypt class can provide the different modes (CBC, ECB, ...) and the different ciphers do the encryption of data, here's an example:
$cr = new Crypt('DES', 'ECB'); $cr->setKey('sss'); $cr->encrypt('sdsdsd'); $cr->decrypt('sdsd');
a _factory method can do something like this:
function _factory($cipher)
{
require_once 'Crypt/Ciphers/' . $cipher . '.php';
$cr = 'Crypt_' . $cipher;
return new $cr;
}
and the constructor of Crypt creates the cipher-class:
function Crypt($cipher, $mode) { ...-- ------------------------------- ------------------------------------- Michael Bretterklieber - Michael.Bretterklieber@jawa.at JAWA Management Software GmbH - http://www.jawa.at Liebenauer Hauptstr. 200 -------------- privat --------------- A-8041 GRAZ GSM: ++43-(0)676-93 96 698 Tel: ++43-(0)316-403274-12 E-mail: michael@bretterklieber.com Fax: ++43-(0)316-403274-10 http://www.bretterklieber.com ------------------------------- ------------------------------------- "...the number of UNIX installations has grown to 10, with more expected..." - Dennis Ritchie and Ken Thompson, June 1972$this->cipher = $this->_factory($cipher);... }