ssbc / ssb2-discussion-forum

not quite tiny, also not quite large
17 stars 1 forks source link

Base64? How about something else #9

Open staltz opened 1 year ago

staltz commented 1 year ago

One of the quirks of working with base64 is that for URIs you have to escape them (+ => - and / => _) and working with this is a pain in the (mini)butt.

Other bases like base58 don't have this problem, and the encoding efficiency is almost the same (73% for base58, 75% for base64). Also base58 is used in bitcoin and others, so implementation is not going to be a problem, it's probably provided already for all languages.

arj03 commented 1 year ago

Oh interesting. That is good input, only be in the application layer, but still worth considering.

staltz commented 1 year ago

Yeah I'm thinking mostly in SSB URIs

gpicron commented 1 year ago

Yes base58 is more or less becoming the standard to encode byte array in URI's

staltz commented 1 year ago

Another benefit of base58 over base64: the padded = which carries no information ends up wasting precious characters, such that it ends up having the same length (in some cases) as the base58 encoding. Example:

base64:
OAiOTCroL1xFxoCKYaZJDTxhLOHaI1cURm/HSPvEy7s=

base58:
4mjQ5aJu378cEu6TksRG3uXAiKFiwGjYQtWAjfVjDAJW

Same string length.