Re: base64_encode without padding

From: Date: Thu, 14 Mar 2024 11:46:46 +0000
Subject: Re: base64_encode without padding
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-122637@lists.php.net to get a copy of this message
On 13-03-2024 17:06, Remi Collet wrote:
I think padding should be optional (on by default to keep BC) Of course in user land, simple to write   $enc = trim(base64_encode('foo'), '='); This proposal allow to simply use   $enc = base64_encode('foo', PHP_BASE64_NO_PADDING); And also expose it for extension as   PHPAPI extern zend_string *php_base64_encode_ex
     (const unsigned char *, size_t, zend_long flags);
Use case: for ARGON2 password hashing see https://github.com/php/php-src/pull/13635 It may seems ugly to add and remove th padding char Is a RFC needed for such a minor feature ? Remi
Great addition! Only I would strongly prefer a boolean argument over a flag. Especially now that we have named arguments, adding a bunch of optional boolean arguments to the signature does not lead to unreadable code anymore. In fact, I think it yields code that is easier to read. Regards, Dik

« previous php.internals (#122637) next »