使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
bytes.to_base64
bytes.to_base64(bytes, optional_default_string)
说明
函数将 bytes
值转换为 base64 encoded string
。如果函数调用包含无法转换的值,则默认返回空字符串。
形参数据类型
BYTES
,STRING
返回类型
STRING
代码示例
从原始二进制字节到 Base64 编码的字符串
该函数将原始二进制字节转换为 base64 编码的字符串。
bytes.to_base64(b'000000006f8ec5586d026f9ddac56e9f2fe15b8a0000000001000000cd000000) = "AAAAAG+OxVhtAm+d2sVuny/hW4oAAAAAAQAAAM0AAAA="
转化失败(默认为可选提供的字符串)
如果提供的字节值无效,该函数会默认返回 "invalid bytes"
。
bytes.to_base64(b'000000006f8ec5586d", "invalid bytes") = "invalid bytes"
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-29。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-07-29。"],[],[],null,["### bytes.to_base64\n\nSupported in: \n[Rules](/chronicle/docs/detection/default-rules) [Search](/chronicle/docs/investigation/udm-search) \n\n bytes.to_base64(bytes, optional_default_string)\n\n#### Description\n\nFunction converts a `bytes` value to a `base64 encoded string`. Function calls with values that cannot be casted return an empty string by default.\n\n#### Param data types\n\n`BYTES`, `STRING`\n\n#### Return type\n\n`STRING`\n\n#### Code samples\n\n##### Raw Binary Bytes to Base64 Encoded String\n\nThe function converts the raw binary bytes to base64 encoded string. \n\n bytes.to_base64(b'000000006f8ec5586d026f9ddac56e9f2fe15b8a0000000001000000cd000000) = \"AAAAAG+OxVhtAm+d2sVuny/hW4oAAAAAAQAAAM0AAAA=\"\n\n##### Failed Conversion (Defaults to the Optionally Provided String)\n\nThe function defaults to the `\"invalid bytes\"` when the bytes value provided isn't valid. \n\n bytes.to_base64(b'000000006f8ec5586d\", \"invalid bytes\") = \"invalid bytes\""]]