使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
strings.from_hex
strings.from_hex(hex_string)
说明
返回与给定十六进制字符串关联的字节。
形参数据类型
STRING
返回类型
BYTES
代码示例
获取与给定十六进制字符串关联的字节。
示例 1
此示例展示了非十六进制字符转换。
strings.from_hex("str") // returns empty bytes
示例 2
此示例显示了输入为空字符串的情况。
strings.from_hex("") // returns empty bytes
示例 3
此示例展示了十六进制字符串转换。
strings.from_hex("1234") // returns 1234 bytes
示例 4
此示例展示了非 ASCII 字符转换。
strings.from_hex("筒纸.中国") // returns empty 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。"],[[["\u003cp\u003e\u003ccode\u003estrings.from_hex\u003c/code\u003e converts a hexadecimal string into its corresponding bytes representation, usable in Rules and Search.\u003c/p\u003e\n"],["\u003cp\u003eThe function accepts a single string parameter (\u003ccode\u003eSTRING\u003c/code\u003e) and returns a \u003ccode\u003eBYTES\u003c/code\u003e data type.\u003c/p\u003e\n"],["\u003cp\u003eProviding a non-hexadecimal string or an empty string to \u003ccode\u003estrings.from_hex\u003c/code\u003e results in empty bytes.\u003c/p\u003e\n"],["\u003cp\u003eOnly hexadecimal strings, like \u003ccode\u003e"1234"\u003c/code\u003e, will be converted successfully to their byte values, as shown in the example.\u003c/p\u003e\n"]]],[],null,["### strings.from_hex\n\nSupported in: \n[Rules](/chronicle/docs/detection/default-rules) [Search](/chronicle/docs/investigation/udm-search) \n\n strings.from_hex(hex_string)\n\n#### Description\n\nReturns the bytes associated with the given hex string.\n\n#### Param data types\n\n`STRING`\n\n#### Return type\n\n`BYTES`\n\n#### Code samples\n\nGet bytes associated with a given hex string.\n\n##### Example 1\n\nThis example shows non-hex character conversions. \n\n strings.from_hex(\"str\") // returns empty bytes\n\n##### Example 2\n\nThis example shows input with empty string. \n\n strings.from_hex(\"\") // returns empty bytes\n\n##### Example 3\n\nThis example shows hex string conversion. \n\n strings.from_hex(\"1234\") // returns 1234 bytes\n\n##### Example 4\n\nThis example shows non-ASCII characters conversion. \n\n strings.from_hex(\"筒纸.中国\") // returns empty bytes"]]