Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

base64 encoding that doesn't use "+/=" (plus or equals) characters?

I need to encode a string of about 1000 characters that can be any byte value (00-FF). I don't want to use Hex because it's not dense enough. the problem with base64 as I understand it is that it includes + / and = which are characters I can not tolerate in my application.

Any suggestions?

like image 484
Peter Kellner Avatar asked Dec 09 '10 07:12

Peter Kellner


People also ask

What characters does Base64 not use?

Show activity on this post. Base64 only contains A–Z , a–z , 0–9 , + , / and = . So the list of characters not to be used is: all possible characters minus the ones mentioned above.

Does Base64 always end with equals?

You will not have an = sign if your string has a multiple of 3 characters, because Base64 encoding takes each three bytes (a character=1 byte) and represents them as four printable characters in the ASCII standard. Base64 deals with the first block (producing 4 characters) and the second (as they are complete).

What does == mean in Base64?

The equals sign "=" represents a padding, usually seen at the end of a Base64 encoded sequence. Each group of six bits is encoded using the above conversion.

Is Base64 always divisible by 4?

With padding, a base64 string always has a length that is a multiple of 4 (if it doesn't, the string has been corrupted for sure) and thus code can easily process that string in a loop that processes 4 characters at a time (always converting 4 input characters to three or less output bytes).


1 Answers

Base58Check is an option. It is starting to become something of a de facto standard in cryptocurrency addresses.

Basic improvements over Base64:

  • Only alphanumeric characters [0-9a-zA-Z]
  • No look-alike characters: 0OIl / 0OIl
  • No punctuation to trigger word wrap or line break in documents and emails
  • Can also select entire value with a single double click due to no punctuation.

The Bitcoin Address Utility is an implementation example; geared for Bitcoins.

Note: A novel de facto standard may not be adequate for your needs. It is unclear if the Base58Check encoding method will formalise across current protocols.

like image 200
LateralFractal Avatar answered Sep 28 '22 15:09

LateralFractal