Trending Technology Machine Learning, Artificial Intelligent, Block Chain, IoT, DevOps, Data Science

Recent Post

Codecademy Code Foundations

Search This Blog

Base - 64 and base - 58 encoding in BlockChain

BASE - 64
  • Base - 64 is basically a way of encoding arbitrary binary data in ASCII text. Base - 64 encoding schemes are commonly used when there is  a need to encode binary data (for example image,audio) that needs to be stored and transferred over media that are designed to deal with textual data. This is to ensure that the data remains intact without modification during transport.
  • Base - 64 encoding schemes uses A-Z, a-z, and 0-9 for the first 62 values, and the symbols + (plus) and / (slash). The = (equal) symbol is used as a padding character.
  • Base - 64 maps 3 bytes (8⤬3=24 bits) in 4 characters that span 6-bits (6⤬4=24 bits). When the number of bytes to encode is not divisible by three that is, if there are only one or two bytes of input for the last 24-bit block, then extra bytes with value zero is added so there are always three bytes.
For example a base - 64 encoded image

  • For example base-64 encode the word "Cat"
  • Cat is represent as a byte sequence of a 8-bit padded ASCII characters.
One the right is the base-64 symbol chart.

Lookup the decimal value in the chart and find its corresponding character in the map.

Decimal value: 16, 54, 5, 52 corresponds to: Q2F0

Thus, the word "Cat" base - 64 encoded: Q2F0

  • For example base - 64 encode the word "Hi"
  •  Add extra byte with value zero so there are always three bytes. 
 BASE - 58
  • Base - 58 encoding schemes also converts binary to alphanumeric text. It is similar to base - 64 encoding without using 0(zero). O (capital o), I (capital i), l (lowercase L), +(plus) and / (slash) because they look the same in some fonts.
  • The base - 58 symbol chart on the right is used in Bitcoin and is specific to the Bitcoin project.
  •  Base - 58 encode the word
  • The word "Cat" in decimal representation: 4415860
  • "Cat" decimal representation: 4415860
  • Remainder values: 22, 36, 39, 30
  • Lookup the remainder values in the base-58 symbol chart.
  • "Cat" base-58 encoded = PdgX

No comments:

Post a Comment

Popular Articles