Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature - Ability to specify GUID or generate pseudo-GUID #13

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

XakerTwo
Copy link
Contributor

@XakerTwo XakerTwo commented Dec 10, 2024

sh script and program now can accept optional -G switch followed by GUID in one of three UUID formats:
windows(38 symbols) - {00000000-0000-4000-8000-000000000000}
general(36 symbols) - 00000000-0000-4000-8000-000000000000
dashless(32 symbols) - 00000000000040008000000000000000

used GUID is UUID version 4 variation 1

if GUID is specified - its certain bytes will be validated according to RFC 9562 section 4.1 and 4.2 plus dash and curly braces, all based on the value length.
if not specified - pseudo-GUID will be generated
if specified GUID is invalid - program will exit with error message and code 1

switch is optional, but default value not specified because value, produced by for-loop is actually invalid UUIDv4.
So you can use one of the GUID that were commented in main() or keep it blank and let program generate it

commented GUIDs in general format:
E36743DD-AB2B-44E1-B7CB-EC31CEB9D5A6
01FCABEF-D84F-4247-A00B-7C788E6DD1C1
5BA57258-F3FE-46CD-913C-EF00C77A9769
5BA57259-F3FE-46CD-913C-EF00C77A9769

note: generator uses srand()(allowed by RFC) and so GUID called pseudo, so you can generate one with other tool and use it

note: sh script not tested on live system, only some constructions, used in it, in online compilers

note: this feature assumed to be merged on top of the time feature, but not necessary. On merging after the time feature there expected few conflicts, be careful with getopt do:h:O:A: lines

add ability to generate pseudo-guid, it uses only srand() and so pseudo
if GUID is not specified - pseudo-guid will be generated
sh also can accept switch -G, but by default this switch is not specified(corresponding variable is empty)

commented guids removed from code and can be found below

proof of GUID on example of values that were commented out in main()

                                             version (4 bits, always 4)
                                             |     variation (2 bits as 0b10, so only 8,9,A,B)
                                             |     |
|         Data1        |   Data2   |   Data3 v |   v                 Data4                     | <- GUID layout
 0xDD, 0x43, 0x67, 0xE3, 0x2B, 0xAB, 0xE1, 0x44, 0xB7, 0xCB, 0xEC, 0x31, 0xCE, 0xB9, 0xD5, 0xA6
 0xEF, 0xAB, 0xFC, 0x01, 0x4F, 0xD8, 0x47, 0x42, 0xA0, 0x0B, 0x7C, 0x78, 0x8E, 0x6D, 0xD1, 0xC1
 0x58, 0x72, 0xA5, 0x5B, 0xFE, 0xF3, 0xCD, 0x46, 0x91, 0x3C, 0xEF, 0x00, 0xC7, 0x7A, 0x97, 0x69
 0x59, 0x72, 0xA5, 0x5B, 0xFE, 0xF3, 0xCD, 0x46, 0x91, 0x3C, 0xEF, 0x00, 0xC7, 0x7A, 0x97, 0x69

why is the version byte mixed up - https://devblogs.microsoft.com/oldnewthing/20220928-00/?p=107221
in short - the GUID is chunked in v1 fashion and stores bytes in each of first three chunks in LE order
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant