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

21,106

Solution 1

As Ciaran says, base64 isn't terribly hard to implement - but you may want to have a look for existing libraries which allow you to specify a custom set of characters to use. I'm pretty sure there are plenty out there, but you haven't specified which platform you need this for.

Basically, you just need 65 ASCII characters which are acceptable - preferably in addition to line breaks.

Solution 2

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.

Solution 3

If it's just those particular characters that bother you, and you can find some other characters to use instead, then how about implementing your own custom base64 module? It's not all that difficult.

Solution 4

You could use Base32 instead. Less dense than Base64, but eliminates unwanted characters completely.

Solution 5

Sure. Why not write your own Base64 encoder/decoder, but replace those chars in your algorithm. Sure, it will not be able to be decoded with a normal decoder, but if that's not an issue, then whyt worry about it. But, you better have at least 3 other chars that ARE useable in your app to represent the +/ and ='s...

Share:
21,106
Peter Kellner
Author by

Peter Kellner

Peter Kellner React, .Net, Ext Training Videos PeterKellner.Net

Updated on July 09, 2022

Comments

  • Peter Kellner
    Peter Kellner almost 2 years

    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?