How Random is System.Guid.NewGuid()? (Take two)

The answer is: You should not need to know this. As stated in the accepted answer to a related question: A GUID doesn’t make guarantees about randomness, it makes guarantees around uniqueness. An even stronger statement on security and randomness is made in RFC4122, which speficies the UUID format: Do not assume that UUIDs are … Read more

What is a good unique PC identifier?

Some good identifiers: MAC Address: It’s fairly easy to get at, and it’s usually unique. However, it can be spoofed/changed rather easily, so it depends on how unique it needs to be. CPU Serial Number: It’s not available on lots of older systems, but it’s there. Check out this MSDN page. It won’t change, but … Read more

How to generate unique 64 bits integers from Python?

just mask the 128bit int >>> import uuid >>> uuid.uuid4().int & (1<<64)-1 9518405196747027403L >>> uuid.uuid4().int & (1<<64)-1 12558137269921983654L These are more or less random, so you have a tiny chance of a collision Perhaps the first 64 bits of uuid1 is safer to use >>> uuid.uuid1().int>>64 9392468011745350111L >>> uuid.uuid1().int>>64 9407757923520418271L >>> uuid.uuid1().int>>64 9418928317413528031L These are … Read more

Why does Guid.ToByteArray() order the bytes the way it does?

If you read the Examples section from the GUID constructor, you’ll find your answer: Guid(1,2,3,new byte[]{0,1,2,3,4,5,6,7}) creates a Guid that corresponds to “00000001-0002-0003-0001-020304050607”. a is a 32-bit integer, b is a 16-bit integer, c is a 16-bit integer, and d is simply 8 bytes. Because a, b, and c are integer types rather than raw … Read more

Sequential Guid Generator

You could just use the same Win32 API function that SQL Server uses: UuidCreateSequential and apply some bit-shifting to put the values into big-endian order. And since you want it in C#: private class NativeMethods { [DllImport(“rpcrt4.dll”, SetLastError=true)] public static extern int UuidCreateSequential(out Guid guid); } public static Guid NewSequentialID() { //Code is released into … Read more

guid to base64, for URL

You might want to check out this site: http://prettycode.org/2009/11/12/short-guid/ It looks very close to what you’re doing. public class ShortGuid { private readonly Guid guid; private readonly string value; /// <summary>Create a 22-character case-sensitive short GUID.</summary> public ShortGuid(Guid guid) { if (guid == null) { throw new ArgumentNullException(“guid”); } this.guid = guid; this.value = Convert.ToBase64String(guid.ToByteArray()) … Read more

How can I generate GUIDs in Excel?

The following Excel expression evaluates to a V4 GUID: =CONCATENATE(DEC2HEX(RANDBETWEEN(0,4294967295),8),”-“,DEC2HEX(RANDBETWEEN(0,65535),4),”-“,DEC2HEX(RANDBETWEEN(16384,20479),4),”-“,DEC2HEX(RANDBETWEEN(32768,49151),4),”-“,DEC2HEX(RANDBETWEEN(0,65535),4),DEC2HEX(RANDBETWEEN(0,4294967295),8)) -or (depending on locale setting/decimal and list separators)- =CONCATENATE(DEC2HEX(RANDBETWEEN(0;4294967295);8);”-“;DEC2HEX(RANDBETWEEN(0;65535);4);”-“;DEC2HEX(RANDBETWEEN(16384;20479);4);”-“;DEC2HEX(RANDBETWEEN(32768;49151);4);”-“;DEC2HEX(RANDBETWEEN(0;65535);4);DEC2HEX(RANDBETWEEN(0;4294967295);8)) Note that the first character of the third group is always 4 to signify a V4 (pseudo-random number generated) GUID/UUID per RFC 4122 section 4.4. Also note that the first character of the fourth group is … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)