Skip to content

ReadFileAsHex (read file bytes)

ts
function ReadFileAsHex(what: string, offset: number, count: number): string;

Reads count bytes from the file specified by what, starting at the given offset. Returns the bytes as a hexadecimal (base16-encoded) string.

ParameterTypeRequirementExplanation
whatstringrequiredPath to a valid, existing file you wish to read
offsetnumberrequiredThe starting byte offset in the file
countnumberrequiredThe number of bytes to read
Return valueExplanation
stringThe base16-encoded (hexadecimal) bytes read from the file

Example

ts
var hexData = ReadFileAsHex('/home/user/data.bin', 0, 16);
Log('First 16 bytes (hex): ' + hexData);