Separate text order from storage order
RFC 9562 §4 defaults to big-endian fields unless an explicit protocol specifies otherwise.
Round-trip the same ID in .NET
We ran this code with .NET 10.0.11 on October 5, 2026. Default ToByteArray() starts with 33 22 11 00 55 44 77 46. ToByteArray(true) starts with 00 11 22 33 44 55 46 77. Both end with 88 99 aa bb cc dd ee ff. Reading the default array with the default constructor restores the original string. For the array produced with true, we paired it with a constructor specifying that endianness. Reversing all 16 bytes matches neither output in this example.
$id = [guid]'00112233-4455-4677-8899-aabbccddeeff'
$bytes = $id.ToByteArray()
($bytes | ForEach-Object { $_.ToString('x2') }) -join ' '
# 33 22 11 00 55 44 77 46 88 99 aa bb cc dd ee ff
([guid]::new($bytes)).ToString()
# 00112233-4455-4677-8899-aabbccddeeff
$network = $id.ToByteArray($true)
([guid]::new($network, $true)).ToString()
# 00112233-4455-4677-8899-aabbccddeeffWhat can you check in Moyoutil?
The current UUID generator creates v4 string lists and changes case or text/JSON display. It does not export binary arrays or convert GUID endianness. Save generated strings as integration test data and align the sending and receiving APIs' byte rules. For a mismatch, compare the string, the 16-byte length, the first three groups, and the final eight bytes in order. We recommend checking the API contract before reversing bytes to force a match.
const id = '00112233-4455-4677-8899-aabbccddeeff';
const hex = id.replaceAll('-', '');
const bytes = Uint8Array.from(hex.match(/../g), s => parseInt(s, 16));
console.log(new TextEncoder().encode(hex).length, bytes.length);
// 32 16Frequently Asked Questions
Is the 32-character string without hyphens a 16-byte file?
No. In the code below, encoding those 32 characters as UTF-8 produces 32 bytes; interpreting each pair of hexadecimal digits produces 16 bytes. Align the input representation before comparing hashes, too.