On Thu, Jun 12, 2025 at 7:23 PM Hans Henrik Bergan <divinit...@gmail.com> wrote:
> On Thu, 12 Jun 2025 at 18:53, ignace nyamagana butera > <nyamsp...@gmail.com> wrote: > > > > Greetings, > > > > I have been playing around with an RFC proposal for some time and > recently after discussing it with Tim Düsterhus he has volunteered > > to do the implementation so I would like to submit to you an RFC around > data encoding in PHP. The goal of the RFC is to fully implement > > RFC4648 (base16 , base32, base64). > > > > I know that PHP already has `base64_encode` and `base64_decode` and > `bih2hex` and `hex2bin` but those functions only provide a partial support > for RFC4648. > > In my RFC proposal I would like to introduce, instead, a new namespace > `Encoding` that will host an all new and improved API which will cover the > complete RFC, > > will be consistent and easily extendable for future data encoding > algorithms addition. > > > > For reference, this is not a new topic, the issue with the current > implementation is well documented in the mailing list as well as a past > attempt to > > add RFC4648 to the language. > > > > - base64_encode without padding https://externals.io/message/122630 > > - base64 url format https://externals.io/message/119243 > > - [RFC] RFC4648 encoding https://externals.io/message/91858#91964 > > > > If people are interested I will proceed with a karma request and create > the draft RFC. > > > > Best regards, > > Ignace Nyamagana Butera > > > Why do it in core? > Is userland base16/base32 performance unsatisfactory? > Hi Hans, If I take base32 as an example, if you look at packagist for userland implementations packages, you will get different results with none telling you which version (alphabet) is being used and if the decoding is strict or not.. The same is true for base64, there are different flavours of base64 with each their usefulness. The RFC will address these issues and provide a consistent API to tackle them. Best regards, Ignace Nyamagana Butera