guid

What are the chances to get a Guid.NewGuid () duplicate? [duplicate]

僤鯓⒐⒋嵵緔 提交于 2019-11-28 09:37:15
Possible Duplicate: Is a GUID unique 100% of the time? Simple proof that GUID is not unique In MSDN you can read: The chance that the value of the new Guid will be all zeros or equal to any other Guid is very low. Say that you have an method that will create a file every second, and you use the method Guid.NewGuid() for filename, is it possible to get the same Guid then? Or will the local computer keep track in some way? How low is the chance ? You would never run out of guids. The likelihood of duplicating them is VERY low: http://betterexplained.com/articles/the-quick-guide-to-guids/ The

How to get friendly device name from DEV_BROADCAST_DEVICEINTERFACE and Device Instance ID

拈花ヽ惹草 提交于 2019-11-28 09:15:40
I've registered a window with RegisterDeviceNotification and can successfully recieve DEV_BROADCAST_DEVICEINTERFACE messages. However, the dbcc_name field in the returned struct is always empty. The struct I have is defined as such: [StructLayout(LayoutKind.Sequential)] public struct DEV_BROADCAST_DEVICEINTERFACE { public int dbcc_size; public int dbcc_devicetype; public int dbcc_reserved; public Guid dbcc_classguid; [MarshalAs(UnmanagedType.LPStr)] public string dbcc_name; } And I'm using Marshal.PtrToStructure on the LParam of the WM_DEVICECHANGE message. Should this be working? Or even

UUID collision risk using different algorithms

浪子不回头ぞ 提交于 2019-11-28 09:04:46
I have a database where 2 (or maybe 3 or 4) different applications are inserting information. The new information has IDs of the type GUID/UUID, but each application is using a different algorithm to generate the IDs. For example, one is using the NHibernate's "guid.comb", other is using the SQLServer's NEWID(), other might want to use .NET's Guid.NewGuid() implementation. Is there an above normal risk of ID collision or duplicates? Thanks! Aaronaught The risk of collisions is elevated slightly but still vanishingly small. Consider that: Both Comb and NEWID / NEWSEQUENTIALID include a

Why is GUID attribute needed in the first place?

只愿长相守 提交于 2019-11-28 08:24:20
What is the necessity for the GUID attribute? why don't just let the compiler handle this automatically?! If the compiler handled this automatically, you'd end up with one of two situations. A new GUID every time you compiled - since GUIDs are supposed to be published, this would fail. Collisions - if the GUID was the same every time, based on (say) a Hash of the name, multiple projects would end up using the same GUID for different purposes. The existing approach - an explicit GUID gives developers the power to control these as required. These are attributes that matter a great deal to COM.

Sequential GUIDs

左心房为你撑大大i 提交于 2019-11-28 07:41:36
I hope someone can answer this question. How does the UuidCreateSequential method in the rpcrt4.dll class use to seed it's guids? I know this much: Microsoft changed the UuidCreate function so it no longer uses the machine's MAC address as part of the UUID. Since CoCreateGuid calls UuidCreate to get its GUID, its output also changed. If you still like the GUIDs to be generated in sequential order (helpful for keeping a related group of GUIDs together in the system registry), you can use the UuidCreateSequential function. The reason behind the question is. If I use this function to generate

Configure Hibernate to use Oracle's SYS_GUID() for Primary Key

こ雲淡風輕ζ 提交于 2019-11-28 07:36:56
问题 I am looking for a way to get hibernate to use oracle's SYS_GUID() function when inserting new rows. Currently my DB tables have SYS_GUID() as the default so if hibernate simply generated SQL that omited the value it should work. I have everything working, but it is currently generating the UUID/GUID in code using the system-uuid generator: @Id @GeneratedValue(generator = "system-uuid") @GenericGenerator(name = "system-uuid", strategy = "uuid") @Column(name = "PRODUCT_ID", unique = true,

How secure are GUIDs in terms of predictability?

霸气de小男生 提交于 2019-11-28 07:33:26
问题 We're using .NET's Guid.NewGuid() to generate activation codes and API keys currently. I wonder if that poses a security problem since their algorithm is open. .NET Guid uses Win32 CoCreateGuid and I don't know its internals (possibly MAC address + timestamp?). Can someone derive a second GUID out of the first one, or can he hit it with some smart guesses or is the randomness good enough so search space becomes too big? Generating random keys have the problem of collision, they need a double

Guid is all 0's (zeros)?

风流意气都作罢 提交于 2019-11-28 07:06:42
I'm testing out some WCF services that send objects with Guids back and forth. In my web app test code, I'm doing the following: var responseObject = proxy.CallService(new RequestObject { Data = "misc. data", Guid = new Guid() }); For some reason, the call to new Guid() is generating Guids with all 0's (zeros) like this: 00000000-0000-0000-0000-000000000000 What could be causing this? Use the static method Guid.NewGuid() instead of calling the default constructor. var responseObject = proxy.CallService(new RequestObject { Data = "misc. data", Guid = Guid.NewGuid() }); Lessons to learn from

Guid Primary /Foreign Key dilemma SQL Server

大城市里の小女人 提交于 2019-11-28 05:33:18
I am faced with the dilemma of changing my primary keys from int identities to Guid. I'll put my problem straight up. It's a typical Retail management app, with POS and back office functionality. Has about 100 tables. The database synchronizes with other databases and receives/ sends new data. Most tables don't have frequent inserts, updates or select statements executing on them. However, some do have frequent inserts and selects on them, eg. products and orders tables. Some tables have upto 4 foreign keys in them. If i changed my primary keys from 'int' to 'Guid', would there be a

kafka监听和处理信息

旧城冷巷雨未停 提交于 2019-11-28 05:25:18
第一种方式 public async Task SendMessageAsync(string topic, string message) { var guid = Guid.NewGuid().ToString("N"); var topics = new List<string> { this._kafkaSetting.ProducerTopics.DeviceTopic, this._kafkaSetting.ProducerTopics.StorageTopic, this._kafkaSetting.ProducerTopics.TaskTopic, this._kafkaSetting.ConsumerTopics.StorageTopic, this._kafkaSetting.ConsumerTopics.TaskTopic }; if (!topics.Contains(topic)) { this._logger?.LogError($"guid:{guid} SendMessageAsync error: ' topic:{topic} error"); return; } this._logger?.LogDebug($"guid:{guid} SendMessageAsync begin: ' topic:{topic},message: