coreutils
[Top][All Lists]
Advanced

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

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


From: Pádraig Brady
Subject: Re: baseN: new program suggestion (various 'base' encoding)
Date: Fri, 23 Nov 2018 13:26:36 -0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0

On 22/11/18 15:26, Assaf Gordon wrote:
> 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

Thanks for summarizing the alternatives.
A single program is definitely the way to go if we're considering adding more 
encodings.

I wonder would basenc be a little more descriptive?
Also a bit of word play in the UNIX tradition :)
In either case neither basen or basenc is present in debian
so we don't need to worry about clashes.

I'd probably change to source file from base64.c to basenc.c

`basen --base64` is a bit more concise than `basen --base=64`,
so I'm OK with either form.

Given the complexity this adds and the disparity
to the proposed alternatives, it seems useful enough to add.

thanks!
Pádraig



reply via email to

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