coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: altchars for base64


From: Assaf Gordon
Subject: Re: altchars for base64
Date: Sun, 15 Mar 2020 10:00:49 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0

Hello,

On 2020-03-15 12:12 a.m., Kaz Kylheku (Coreutils) wrote:
On 2020-03-14 22:20, Peng Yu wrote:
Python base64 decoder has the altchars option.
[...]
But I don't see such an option in coreutils' base64. Can this option
be added? Thanks.

# use %* instead of +/:
base64 whatever | tr '+/' '%*'

The reason for alternative characters is typically do use then in URLs,
where "/" and "+" are problematic.

A new command "basenc" was introduced in coreutils version 8.31
(released last year) which supports multiple encodings.
One of these is a "web-safe" variant of base64, as defined in
RFC4648 section 5:

  $ printf '\376\117\202' | basenc --base64
  /k+C

  $ printf '\376\117\202' | basenc --base64url
  _k-C

regards,
 - assaf

P.S.
The other supported encodings are (basenc --help):

  --base64          same as 'base64' program (RFC4648 section 4)
  --base64url       file- and url-safe base64 (RFC4648 section 5)
  --base32          same as 'base32' program (RFC4648 section 6)
  --base32hex       extended hex alphabet base32 (RFC4648 section 7)
  --base16          hex encoding (RFC4648 section 8)
  --base2msbf       bit string with most significant bit (msb) first
  --base2lsbf       bit string with least significant bit (lsb) first







reply via email to

[Prev in Thread] Current Thread [Next in Thread]