JWT - Here you have a full implementation in the ILEastic library.

https://github.com/sitemule/ILEastic/tree/master/plugins/jwt


On Tue, Mar 11, 2025 at 3:20 AM Vern Hamberg via MIDRANGE-L <
midrange-l@xxxxxxxxxxxxxxxxxx> wrote:

Hi Chris

As I understand it, and I think Jay mentioned it, the so-called BASE4
part is actually BASE64URL - this replaces a couple things in BASE64
that don't work in URLs - like a forward slash, I believe. I forget, but
I looked it up.

--

*Regards*

*Vern Hamberg*

IBM Champion 2025 <cid:part1.yF3xcJ7F.stqK4olY@centurylink.net> CAAC
(COMMON Americas Advisory Council) IBM Influencer 2023

On 3/10/2025 2:58 PM, Hiebert, Chris via MIDRANGE-L wrote:
From my understanding, you need to split the three strings before you
attempt to base64 decode.


A snipped from my RPG code uses:


TokenID Varchar(512);

Dcl-s splitSession Varchar(512) dim(3);
Dcl-s decoded_key char(4096) CCSID(*UTF8);

splitSession = %Split( TokenID :'.');

len = base64_decode( %Addr( splitSession(2) :*data ) :
%len(splitSession(2))
: %Addr( decoded_key ) : %Size( decoded_key ) );


Then parse the Json string now contained in decoded_key.

I imported Scott Klement’s BASE64R4 service program code a few years go
and use that base64_decode procedure in RPG.


Also, you shouldn’t need to Cast your string to 1208. Once decoded it
should BE 1208 already.



--
Chris Hiebert
Lead Software Developer
Disclaimer: Any views or opinions presented are solely those of the
author and do not necessarily represent those of the company.

From: MIDRANGE-L<midrange-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of
Jay Vaughn
Sent: Wednesday, March 5, 2025 11:50 AM
To: Midrange Systems Technical Discussion<midrange-l@xxxxxxxxxxxxxxxxxx>
Subject: Re: base64 URL decode - for jwt


yeah this is definitely the piece I cannot hack.



I did a base64 encode in another project and before the encoding I'd

declare an rpg variable as varchar(256) and ccsid(1208)

then base64 encode would work fine.



but



base64_decode will result in a blob...



and even though I'm doing a...



set o_token = cast( qsys2.base64_decode(trim(i_token))

as varchar(2048) ccsid 1208);



It is still not legible. (even if I remove the ccsid 1208 - it is not

legible.



Daniel, are you able to reference any live code and tell me which part
I'm

missing here?



thanks



Jay
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/midrange-l.

Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription related
questions.



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.