Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:119253 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 71473 invoked from network); 10 Jan 2023 14:44:02 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 10 Jan 2023 14:44:02 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id A72B41804AB for ; Tue, 10 Jan 2023 06:44:01 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS19151 66.111.4.0/24 X-Spam-Virus: No X-Envelope-From: Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 10 Jan 2023 06:44:01 -0800 (PST) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 6E8195C00DF for ; Tue, 10 Jan 2023 09:44:00 -0500 (EST) Received: from imap50 ([10.202.2.100]) by compute4.internal (MEProxy); Tue, 10 Jan 2023 09:44:00 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= garfieldtech.com; h=cc:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm3; t=1673361840; x= 1673448240; bh=TPVE6gOhNIlEEO900Hi1JgZyB/Tyg3MfE9FptLQpEfE=; b=c wmnXmFA0V643vOUdkASb3Nrj9dfke0Fclc71TjWV2xXOLG+IYWLw45UgxPCRn6pd KJdr+r4FOBtAFMCHphQUK+99HMXSLDEJIBjiFM+8qHnausBuCxqo9R6/6ZTbsP1P mUV083V4ujTXi5GtLnE6hVyCtCDjw+RgqmfVqnALLVXa6MQxJO2ZJ7HIa/pVohcE gM4jZ349eWYL0o9UolYooTI1XpIRC5S3VOeha47mSh4c8vkcHTz7C26FueH8WdEs CQw0E5BsJwQWVXOz42YKW4+meJQgVC4kfqYTChCuqHRjg8wGlbm/QLIrgVtoqO3m Cg91oA60frb1ejd8q3M0A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:sender:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; t=1673361840; x=1673448240; bh=TPVE6gOhNIlEEO900Hi1JgZyB/Ty g3MfE9FptLQpEfE=; b=kHBbCemF63+N5lmJ6UuijKGGJs5T9Qv2My48uacGxVNu X17O3mLauqBOJiV16GGli5VivFeAF9Szgd+9UtkvB2yZuy7GmnJo5VvQNA7gnCu3 TxXpWf9BY33mNgKTsoA7RmK5yfOR9VoQoEFW9TC7q9njHsLD5etGN8l6CGhuCZOu 8gg7V5UYz2qqJfjcmMZFqkI/OOwBm23IFrDtyeA25+NQxfCI4hY4A8J92OL4ymcU 7go5n43V6ajOUspqMHFKmbe8m0so1Smyhl2ZJevVEmd/+pswKpUjeZEmzGYLw9fa KRHCH41OpBLaOvjY/xw9plvPI10cXewdiDSUZR7P6g== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrledvgddtgecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefofgggkfgjfhffhffvufgtsehttdertderredtnecuhfhrohhmpedfnfgrrhhr hicuifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfhhivghlughtvggthhdrtghomh eqnecuggftrfgrthhtvghrnheptdetgfehiedtgffgtefhgefffeffhefgvddttedvueej ueelgfdufefftdfhgfefnecuffhomhgrihhnpehrfhgtqdgvughithhorhdrohhrghenuc evlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehlrghrrhih sehgrghrfhhivghlughtvggthhdrtghomh X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 386EA1700089; Tue, 10 Jan 2023 09:44:00 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.7.0-alpha0-1185-g841157300a-fm-20221208.002-g84115730 Mime-Version: 1.0 Message-ID: <2c700f58-cdb6-49b1-b40a-b92cc69bf0fe@app.fastmail.com> In-Reply-To: References: Date: Tue, 10 Jan 2023 08:43:39 -0600 To: "php internals" Content-Type: text/plain Subject: Re: [PHP-DEV] base64url format From: larry@garfieldtech.com ("Larry Garfield") On Mon, Jan 9, 2023, at 12:49 PM, Sara Golemon wrote: > I've been working with JWTs lately and that means working with Base64URL > format. (Ref: https://www.rfc-editor.org/rfc/rfc4648#section-5 ) > This is essentially the same thing as normal Base64, but instead of '+' and > '/', it uses '-' and '_', respectively. It also allows leaving off the > training '=' padding characters. > > So far, I've just been including polyfills like this: > > function base64url_decode(string $str): string { > return base64_decode(str_pad(strtr($str, '-_', '+/'), (4 - > (strlen($str) % 4)) % 4, '=')); > } > > function base64_encode(string $str): string { > return rtrim(strtr(base64_encode($str), '+/', '-_'), '='); > } > > These work fine, but they create a LOT of string copies along the way which > shouldn't be necessary. > Would anyone mind if skipped RFC and just added `base64url_encode()` and > `base64url_decode()` to PHP 8.3? > > Can hold a vote if anyone objects, but this seems fairly non-controversial. > > -Sara It sounds to me like there's enough discussion to be had on the How to warrant a formal RFC. I get the sense once the bikeshedding is done it will pass, but it's going to need the discussion/review. --Larry Garfield