RE: [PEAR-DEV] Proposed new package

From: Date: Tue, 18 Feb 2003 05:48:49 +0000
Subject: RE: [PEAR-DEV] Proposed new package
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-13436@lists.php.net to get a copy of this message
The finished abstraction class will be able automatically incorporate and use whatever algorithms are provided as modules. As I have it now, this would be the usage for DES (and other symmetric ciphers): $des = Crypt::init('DES'); $data = 'my data'; $key = 'my key'; $mode = 'ecb'; $cipherText = $des->encrypt($data, $key, $mode); $clearText = $des->decrypt($cipherText, $key, $mode); Usage for RSA (and other asymmetric ciphers): $rsa = Crypt::init('RSA'); $data = 'my data'; $keyPublic = 'Public RSA key'; $keyPrivate = 'Private RSA key'; $cipherText = $rsa->encrypt($data, $keyPrivate); $clearText = $rsa->decrypt($cipherText, $keyPublic); Usage for MD5 (and other digest/hash algorithms) $md5 = Crypt::init('md5'); $data = 'my data'; $hash = $md5->encrypt($data); This abstraction class cleanly unifies the interfaces of the various encryption schemes out there today. It also implements class overrides in a way that allows true modularity. Say for example the module DES implements not only the minimum encryption and decryption methods, but also implements a method that generates key parity (which it does). Say also that the system the module is running on has mcrypt loaded. The abstraction class would make the mcrypt module a child of the DES module, overriding the encrypt and decrypt methods with the much faster mcrypt wrappers, while leaving addon methods like parity() intact. Example: $des = Crypt::init('DES'); $data = 'my data'; $key = $des->parity('my key'); // This call is handled by the Crypt_DES module $mode = 'ecb'; $cipherText = $des->encrypt($data, $key, $mode); // These calls are handled by the Crypt_Mcrypt module $clearText = $des->decrypt($cipherText, $key, $mode); // These calls are handled by the Crypt_Mcrypt module How does this strike you? pear-dev@lists.php.net -----Original Message----- From: Mirco 'meebey' Bauer [mailto:pear-dev@meebey.net] Sent: Monday, February 17, 2003 3:18 PM To: pear-dev Subject: Re: [PEAR-DEV] Proposed new package > > I'm also +1 on this, even though I can't have a look at the code atm, > because Mutt doesn't seem to be able to encrypt it automatically. that happened because he was using a broken non-RFC MUA :) I got the same problem.... > > > I was wondering... since there are some crypto classes already, > > shouldn't we build a wrapper to access them all with a common API > > (limited to what is possible, of course!)? I'm thinking about > > something > > like: $mycrypt = new Crypto_Wrapper(array('algorithm' =>'TRIPLEDES')); > > That would be great and it would definitively be a shining example for > other categories in PEAR. > > -- > - Martin Martin Jansen > http://martinjansen.com/ > > -- > PEAR Development Mailing List (http://pear.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > Mirco Bauer aka MEEBEY -----BEGIN GEEK CODE BLOCK----- Version: 3.12 GIT d s-: a--- C++ UL++>++++ P L++$>+++$ E W+++$ N o? K- w++>! O- M- V? PS PE+ Y- PGP>++ t 5+ X++ R tv+ b+ DI? D+ G>++ e h! r>++ y? ------END GEEK CODE BLOCK------ -- PEAR Development Mailing List (http://pear.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.pear.dev (#13436) next »