educative.io

Why do we encode the hash value?

“We can compute a unique hash (e.g., MD5 or SHA256 etc.) of the given URL. The hash can then be encoded for display. This Base64 encoding could be base36 ([a-z ,0-9]) or base62 ([A-Z, a-z, 0-9]) and if we add ‘+’ and ‘/’ we can use encoding”

Why cant we just grab the short key directly from the hash value? What is the purpose of the Base 64 encoding?

@Trevor_Stockert

Base64 encoding is used for passing data in URLs when the data includes non-URL-friendly characters. Also, Base64 encoding defines how to represent binary data in an ASCII string format. The objective of base64 encoding is to transmit binary data such as keys or digital certificates in a printable format. This type of encoding is needed if these objects are transported as part of an email body, a web page, an XML document, or a JSON document.