Re: base64_encode without padding

From: Date: Thu, 14 Mar 2024 20:31:17 +0000
Subject: Re: base64_encode without padding
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-122643@lists.php.net to get a copy of this message
> > 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); > > Please add PHP_BASE64_URL flag also. BASE64 URL encoding (URL safe Base64 encoding) is used everywhere. i.e. str_replace(['+','/','='], ['-','_',''], base64_encode($str); https://base64.guru/standards/base64url Decoding should be extended. i.e. base64_decode($encoded, PHP_BASE64_URL) Adding PHP_BASE64_STRICT flag may be reasonable, that requires specific encoding strictly for decoding. Regards, -- Yasuo Ohgaki yohgaki@ohgaki.net > 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 >

« previous php.internals (#122643) next »