English 中文(简体)
Is there a way to distinguish a GUID from just a random number?
原标题:

Being able to distinguish a GUID from random data can be useful when debugging obscure code defects.

On Windows each GUID generated is of version 4 therefore it has 4 as the first half-byte of the third part. So if the 16-byte sequence violtates that rule it is not a version 4 GUID. For example,

567E1ECB-EA1C-42D3-A3ED-87A5D824D167

could be either a version 4 GUID or anything else, but

567E1ECB-EA1C-02D3-A3ED-87A5D824D167 //third section starts with 0, not with 4

is not a version 4 GUID.

What are other signs of a 16-byte memory block being or not being a valid GUID?

问题回答

GUID s are hexadecimal, so you could check what characters are included (i.e. X , Y , etc. are not valid)

Check wikipedia for the definition and you could probably find out more ideas there.

http://en.wikipedia.org/wiki/Globally_Unique_Identifier

Besides GUID version (0100), there s also something called the GUID variant. This will be 2 bits (10) in octet 8. The remaining bits a of v4 GUID are by definition random.





相关问题
Weighted random numbers

I m trying to implement a weighted random numbers. I m currently just banging my head against the wall and cannot figure this out. In my project (Hold em hand-ranges, subjective all-in equity ...

Comprehensive information about hash salts

There are a lot of questions about salts and best practices, however most of them simply answer very specific questions about them. I have several questions which feed into one another. Assuming a ...

Generate unique names?

I am working on a php site in which we have to upload images from users.i have to rename that file for preventing conflicts in the name of the image. uniqid(rand(), true); and adding a large random ...

How to get two random records with Django

How do I get two distinct random records using Django? I ve seen questions about how to get one but I need to get two random records and they must differ.

What is suggested seed value to use with random.seed()?

Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...

热门标签