Base62

from Wikipedia, the free encyclopedia

Base62 is a place value system for base 62, which is used to encode large numbers using ASCII characters. The numbers 0–9 (value 0–9), capital letters A – Z (value 10–35) and lower case letters a – z (value 36–61) are used.

The high number base results in shorter strings than with the decimal or hexadecimal system , which offers two advantages in particular:

  • In this way they can be entered by a person more quickly and with less risk of error. A font should be selected in which confusable letters such as lowercase L and uppercase i or the number zero and uppercase O can be distinguished.
  • Length restrictions, e.g. B. If a number is to be used as part of an identifier or file name, this can be bypassed. It should be noted, however, that the processing system recognizes the difference between upper and lower case.

appraisal

The length of a coding in Base62 can be estimated using the following formula:

with s as the number of digits in the base-62 number system, n as the number of digits in the system for base b. The formula shows that favorable compression can be achieved with a small b.

Examples:

  • A number of the type long integer (b = 2) with 32 bits, of which 31 bits (n = 31) can be used because only positive numbers can be used for the counter, requires a maximum of 6 digits.
  • A 128-digit binary number (n = 128, b = 2) can be encoded in the number system to base 62 with 22 characters, but requires 32 hexadecimal and 39 decimal digits.
  • An 8-digit bank code (n = 8, b = 10) can be coded with 5 digits to base 62.

Areas of application

Typical applications are hash codes , keys in cryptology and automatically generated PINs . Base62 is also used to compress JavaScript in order to keep the overall size of web pages with high amounts of JavaScript smaller.

Since Base62 does not contain any special characters, this method can also be used in URLs and other identifiers . However, Base64 , for example, can be encoded and decoded more efficiently.

See also

Individual evidence

  1. The JavaScript compressor "Packer" by Dean Edwards