Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

python

What is base64.a85encode in Python?

Sarvech Qadir

Base64 coding refers to encoding data from binary to text. This translates binary data to a radix-64 format in order to represent binary data in an ASCII string format.

There are many methods that are part of the Python base64 module. base64.a85encode is one of the methods of the base64 library. a85encode is used to encode bytes-like objects to ASCII using the ASCII85 alphabet.

Syntax

base64.a85encode(b, foldspaces=False, wrapcol=0, pad=False, adobe=False)
  1. b: A bytes-like object.

  2. foldspaces: If True, the 4 consecutive spaces will be replaced by a character y.

  3. wrapcol: Refers to the count of characters before a new line is encountered.

  4. pad: If True, the bytes-like object is padded in a multiple of 4.

  5. adobe: If True, the encoded string is written between <~ and ~>.

The parameters do not have a significant impact when False.

Code

import base64

# Data
data = "Welcome to Educative"
print("data:", data)
# converting the data to bytes-form
data_bytes = data.encode("UTF-8")
# perform the a85 encode function
result = base64.a85encode(data_bytes)
result1 = base64.a85encode(data_bytes, adobe=True)
print("a85encoded: ", result)
print("with adobe: ", result1)

## We can use a85decode function to perform reverse operation.

result1 = base64.a85decode(result)
print("a85decoded: ", result1)

RELATED TAGS

python

CONTRIBUTOR

Sarvech Qadir
Copyright ©2022 Educative, Inc. All rights reserved
RELATED COURSES

View all Courses

Keep Exploring