base85 Algorithm

The Base85 algorithm, also known as Ascii85, is an encoding technique that transforms binary data into a compact textual representation, primarily for the purpose of data transfer and storage. It is an extension of the more widely used Base64 encoding system, which uses a set of 64 characters to represent data. Base85, on the other hand, employs an expanded set of 85 characters, providing a more efficient and space-saving representation of data. This algorithm is particularly useful in scenarios where storage space or transmission bandwidth is limited and a compact data representation is needed. It has been utilized in several applications, such as Adobe's PostScript and PDF file formats, as well as Git version control system for encoding binary files. The Base85 algorithm works by packing four bytes (32 bits) of binary data into a five-character group, where each character is selected from a predefined set of 85 characters (typically ASCII characters 33-117). The encoding process involves dividing the 32-bit binary data into five 5-bit groups, and then using each 5-bit group as an index to select a corresponding character from the predefined character set. This results in a 25% increase in size compared to the original binary data, in contrast to Base64's 33% expansion. The encoded output can be easily transmitted over communication channels or stored in text-based formats. To decode the data, the reverse process is employed, where the five-character group is mapped back to its corresponding 5-bit groups, which are then reassembled into the original 32-bit binary data.
import base64


def main():
    inp = input("->")
    encoded = inp.encode("utf-8")  # encoded the input (we need a bytes like object)
    a85encoded = base64.a85encode(encoded)  # a85encoded the encoded string
    print(a85encoded)
    print(base64.a85decode(a85encoded).decode("utf-8"))  # decoded it


if __name__ == "__main__":
    main()

LANGUAGE:

DARK MODE: