hutool.core.codec¶
编解码工具类,提供Base64、Base32等编解码功能
Module Contents¶
Classes¶
Data¶
API¶
- hutool.core.codec.__all__ = ('Base32', 'Base64')¶
- class hutool.core.codec.Base64¶
Base64编解码工具类
- static encode(data: bytes) str¶
编码字节数据为Base64字符串
- 参数:
data – 待编码的字节数据
- 返回:
Base64编码字符串
- static encode_str(data: str, charset: str = 'utf-8') str¶
编码字符串为Base64字符串
- 参数:
data – 待编码的字符串
charset – 字符编码,默认utf-8
- 返回:
Base64编码字符串
- static decode(base64_str: str) bytes¶
解码Base64字符串为字节数据
- 参数:
base64_str – Base64编码字符串
- 返回:
解码后的字节数据
- static decode_str(base64_str: str, charset: str = 'utf-8') str¶
解码Base64字符串为字符串
- 参数:
base64_str – Base64编码字符串
charset – 字符编码,默认utf-8
- 返回:
解码后的字符串
- static encode_url_safe(data: bytes) str¶
编码为URL安全的Base64字符串(使用-和_代替+和/)
- 参数:
data – 待编码的字节数据
- 返回:
URL安全的Base64编码字符串
- static decode_url_safe(base64_str: str) bytes¶
解码URL安全的Base64字符串
- 参数:
base64_str – URL安全的Base64编码字符串
- 返回:
解码后的字节数据