파이썬[Python]: base64 - a85encode 함수

파이썬(Phthon): base64 모듈 - a85encode 함수(function)


/// 설명

Ascii85를 사용하여 바이트 객체를 인코딩합니다.
foldspaces=True 이면 '20202020(16)'을 'y'로 변환합니다.'btoa'에서 사용되며 표준 ascii85 인코딩에서는 사용되지 않습니다.
wrapcol은 개행문자('\n')를 바이트 객체에 입력합니다. 숫자의 크기는 몇 Byte단위로 개행문자를 입력할 것인지 설정합니다.
pad는 원본 바이트 객체를 4 Byte의 배수에 맞추어 인코딩합니다. 'btoa'는 항상 이 속성을 사용합니다.
adobe는 Adobe를 구현하는데 있어서 인코딩의 시작과 끝에 '<~', '~>'를 입력합니다.

※ 형식
base64.a85encode(bytes, *, folspaces=False, wrapcol=0, pad=False, adobe=False)

reference
https://docs.python.org/3/library/base64.html#module-base64

/// 예제

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
from base64 import *
 
# Ascii85 encoding
test_bytes1 = b'byte'  # is a multiple of 4 Byte
test_bytes2 = b'byte\x20\x20\x20\x20'
test_bytes3 = b'byt'  # is not a multiple of 4 Byte
test_encode1 = a85encode(test_bytes1)
test_encode2 = a85encode(test_bytes2, foldspaces=True)
test_encode3 = a85encode(test_bytes1, wrapcol=1)
test_encode4 = a85encode(test_bytes3, pad=True)
test_encode5 = a85encode(test_bytes1, adobe=True)
 
print('Ascii85               :', test_encode1)  # Ascii85               : b"@X3',"
print('Ascii85 with foldspace:', test_encode2)  # Ascii85 with foldspace: b"@X3',y"
print('Ascii85 with wrapcol  :', test_encode3)  # Ascii85 with wrapcol  : b"@\nX\n3\n'\n,"
print('Ascii85 with pad      :', test_encode4)  # Ascii85 with pad      : b'@X3%q'
print('Ascii85 with adobe    :', test_encode5)  # Ascii85 with adobe    : b"<~@X3',~>"
 
cs

* 실행환경: Microsoft Windows 10 Homes
* 인터프리터: 파이썬(Python 3.9)


– 당신을 응원합니다. –

댓글

이 블로그의 인기 게시물

파이썬[Python]: 내장함수 - from_bytes 메서드

파이썬[Python]: 내장함수 - __len__ 메서드

파이썬[Python]: kivy - 한글 사용

파이썬[Python]: 내장함수 - bit_length 메서드

C 언어: sin 함수, cos 함수, tan 함수