coreutils
[Top][All Lists]
Advanced

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

baseN: new program suggestion (various 'base' encoding)


From: Assaf Gordon
Subject: baseN: new program suggestion (various 'base' encoding)
Date: Thu, 22 Nov 2018 16:26:11 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0

Hello all,

I recently needed some less common binary encoding,
and decided to try and implement it based on base64.c .

Various encoding have been discussed in the past,
and there's always the trade off between usefulness
and bloat.

The attached patch implements a new program (tentatively 'basen')
which accepts the encoding as a parameter:
      --base64
      --base64url
      --base32
      --base32hex
      --base16
      --base85
      --z85

This is just a draft, some more work is required to make it
production ready (e.g. tests, docs, and non-ASCII support).

Since it is a new program, changing options won't break backwards-
compatibility, and adding new encodings won't be distruptive
(or add more executables in /usr/bin ).

For completeness, here are alternatives using existing programs:

====

base16 encode:
   od -tx1 -An FILE | sed 's/ //g'

base16 decode:
   xxd -p -r FILE
   (but not "xxd -pr")

   printf $(printf "68656c6c6f" | sed -E 's/(..)/\\x\1/g')

base32hex encode:

base32 FILE | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ234567 0123456789ABCDEFGHIJKLMNOPQRSTUV

base32hex decode:

tr 0123456789ABCDEFGHIJKLMNOPQRSTUV ABCDEFGHIJKLMNOPQRSTUVWXYZ234567 FILE | base32 -d

---

base64url encode:

    base64 | tr '+/' '-_'

base64url decode:

    tr '-_' '+/' | base64 -d

====


Comments and opinions very welcomed.
regards,
 - assaf




reply via email to

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