On 2 February 2015 at 14:30, Daniel Lowrey <rdlow...@php.net> wrote:
>> The extra params aren't really _that_ bad.
>
> Okay, I'd like to reset the conversation a bit here. It's clear that the
> current API does not fit the problem domain very well. Tacking on more
> parameters only creates a bigger mess. Six parameters to a stateless
> function call is a completely incoherent API. It's unusable without
> consulting the manual. I think we need a completely different approach. Let
> me propose something else that won't break BC in any release and results in
> an API that's actually sane:
>
> class CryptoContext {
>     private $mode;
>     private $password;
>     function __construct($mode, $password) {
>         $this->mode = $mode;
>         $this->password = $password;
>     }
>     function encrypt($data) {
>         // ...
>         return $encryptedData;
>     }
>     function decrypt($data) {
>         // ...
>         return $decryptedData;
>     }
>     function setOption($option, $value) {
>         // ...
>     }
>     // more methods here to do anything you need
> }
>
> Thoughts on a stateful object API here? Personally I find this much more
> coherent than anything that's been proposed so far and it could be
> implemented without affecting existing functionality.

I'd really love to move to a context based crypto API.

I'd go one further and say I'd really love to see an extensible crypto
API, where extensions could provide ciphers or modes not available in
core.

That works for me going forward, but I'd still like a solution that
can go into 5.x

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to