From: Gustaf N. <ne...@wu...> - 2020-05-25 11:55:57
|
NaviServer has native support for base64 and base64url encoding/decoding See: https://naviserver.sourceforge.io/n/naviserver/files/ns_base64.html -gn On 25.05.20 03:23, Maksym Zinchenko wrote: > As I understood, you want to send data to your REST API in url, so you > cant use ns_base64encodin. > Because its base64 not base64url. > May be some of this will be helpful: > https://wiki.tcl-lang.org/page/base64 > https://wiki.tcl-lang.org/page/base64url > > Chilkat: > https://www.example-code.com/tcl/base64url_encoding.asp > > On Mon, May 25, 2020 at 12:08 AM Maksym Zinchenko <siq...@gm... > <mailto:siq...@gm...>> wrote: > > What do you mean its not encoded correctly? > > ns_base64decode > eydpc3MnOiAnMjY5NzM0MTAwMDAxMDInLCAnYXVkJzogJ2l1cml4LmNvbS9SRVNUJywgJ3N1Yic > 6ICc3MDQnLCAnaWF0JzogMTU5MDM2NTY1MH0= > {'iss': '26973410000102', 'aud': 'iurix.com/REST > <http://iurix.com/REST>', 'sub': '704', 'iat': 1590365650} > > > On Sun, May 24, 2020 at 11:56 PM Maksym Zinchenko > <siq...@gm... <mailto:siq...@gm...>> wrote: > > sourcecode/nsd/uuencode.c maybe > > On Sun, May 24, 2020 at 11:23 PM Iuri de Araujo Sampaio > <iu...@iu... <mailto:iu...@iu...>> wrote: > > Hi there, > > It looks like *[ns_base64encode]* generates a wrong > payload when message size contains more than 63 characters. > > https://tools.ietf.org/html/rfc4648#section-5 > > An alternative alphabet has been suggested that would use "~" as the > 63rd character. > > > > (1) Payload, which generates a proper encryption. > setpayload [ns_base64encode "{'sub': '$user(user_id)', > 'it': [ns_time]}”] > > eydzdWInOiAnNzA0JywgJ2lhdCc6IDE1OTAzNjU2ODF9 > > (2) Payload, which generates a wrong encryption > > setpayload [ns_base64encode "{'iss': '26973410000102', > 'aud': 'iurix.com/REST <http://iurix.com/REST>', 'sub': > '$user(user_id)', 'iat': [ns_time]}”] > eydpc3MnOiAnMjY5NzM0MTAwMDAxMDInLCAnYXVkJzogJ2l1cml4LmNvbS9SRVNUJywgJ3N1Yic6ICc3MDQnLCAnaWF0JzogMTU5MDM2NTY1MH0= > > > item (2) is not encoded correctly using base64url > (https://tools.ietf.org/html/rfc4648#section-5). Note that > padding ("=") must be omitted as per > https://tools.ietf.org/html/rfc7515#section-2 > > How would I use [ns_base64encoding], if i decide to add > more content in the payload message? Is it possible? > > I was trying find where ns_base64encoding is implemented, > within Naviserver source code. But I haven’t found yet. > Then I’d be able to go deeper into the problem to identify > the actual cause and try to write a solution to it. > > Does anyone know where is the implementation of > [ns_base64encode] ? > > Best wishes, > I > |