guid

How short can a GUID be?

梦想与她 提交于 2019-12-03 05:01:27
I know the standard GUIDs. Can they be made shorter? What is the theory behind it? Greg Dean's answer is correct but in order to understand how a GUID is generated and why it ought not to be shortened I would highly suggest you read the article below. The Old New Thing : GUIDs are globally unique, but substrings of GUIDs aren't : A customer needed to generate an 8-byte unique value, and their initial idea was to generate a GUID and throw away the second half, keeping the first eight bytes. They wanted to know if this was a good idea. No, it's not a good idea. The GUID generation algorithm

Best practice on generating reset password tokens

混江龙づ霸主 提交于 2019-12-03 03:59:06
问题 Any best practice on how a reset password token should be constructed? I'm thinking: random 17 characters [a-zA-Z0-9] + a globally unique id + random 17 characters [a-zA-Z0-9]. Is there a better solution, or an industry standard on reset password tokens? 回答1: There are some important points to consider. The code should be really random (read from MCRYPT_DEV_URANDOM), and should not be derrived from other user related information. Ideally the code is base62 encoded (A-Z a-z 0-9) to avoid

I need to generate uuid for my rails application. What are the options(gems) I have? [duplicate]

南楼画角 提交于 2019-12-03 03:23:24
问题 This question already has answers here : Generating Guids in Ruby (10 answers) Closed 3 years ago . I use Rails 3.0.20 and ruby 1.8.7 (2011-06-30 patchlevel 352) Please suggest me the best plugin to generate guid. 回答1: There are plenty of options, I recommend not to add additional dependencies and use SecureRandom which is builtin: SecureRandom.uuid #=> "1ca71cd6-08c4-4855-9381-2f41aeffe59c" See other possible formats here. 回答2: The first thing I would suggest is that please upgrade your ruby

Enumerate all AppDomains without mscoree

匿名 (未验证) 提交于 2019-12-03 03:10:03
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: How to enumerate all the process' domains without referencing mscoree . Is it possible? I found some solution from 2007 year somewhere in the Internet. But it enumerates and empty collection. Here's the code: public static class DomainHelper { public static AppDomain[] LoadedDomains { get { var loadedDomains = new List<AppDomain>(); var runtimeHost = new CorRuntimeHost() as ICorRuntimeHost; try { var enumeration = IntPtr.Zero; runtimeHost.EnumDomains(out enumeration); try { object nextDomain = null; runtimeHost.NextDomain(enumeration, ref

GUID: varchar(36) versus uniqueidentifier

匿名 (未验证) 提交于 2019-12-03 03:04:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm working with a legacy database that stores GUID values as a varchar(36) data type: CREATE TABLE T_Rows ( RowID VARCHAR(36) NOT NULL PRIMARY KEY, RowValue INT NOT NULL ) INSERT T_Rows (RowID, RowValue) VALUES (NEWID(), 1) I would assume that storing a GUID as a uniqueidentifier would be preferable since it's only 16 bytes in size as opposed to 36. Are there any advantages to storing a GUID as a varchar? 回答1: Perhaps only the fact that you can 'read' them from a SELECT statement (although I don't think that's particularly useful as you can

Convert byte[] or object to GUID

匿名 (未验证) 提交于 2019-12-03 03:04:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I assigned some value to object data type like, object objData =dc.GetDirectoryEntry().Properties["objectGUID"].Value; this object retun the value like {byte[16]} [0]: 145 [1]: 104 [2]: 117 [3]: 139 [4]: 124 [5]: 15 [6]: 255 [7]: 68 [8]: 142 [9]: 159 [10]: 208 [11]: 102 [12]: 148 [13]: 157 [14]: 179 [15]: 75 Then i casting this object to byte[], like byte[] binaryData = objData as byte[]; It will also return like, {byte[16]} [0]: 145 [1]: 104 [2]: 117 [3]: 139 [4]: 124 [5]: 15 [6]: 255 [7]: 68 [8]: 142 [9]: 159 [10]: 208 [11]: 102 [12]: 148

Generate Guid on Serverside Entity Framework 5?

情到浓时终转凉″ 提交于 2019-12-03 03:02:25
I am coming from a nhibernate background and I am wondering how can I generate the Guid automatically on the serer side and not make a round trip to make it on the database side? In fluent nhibernate it is simple just Id(x => x.Id).GeneratedBy.GuidComb(); Richard If you want to generate the key on the server, simply do this in code: public class TestObject { public TestObject() { Id = Guid.NewGuid(); } public Guid Id { get; set; } } If you want the database to generate the key, then use the DatabaseGenerated attribute: public class TestObject { [DatabaseGenerated(DatabaseGeneratedOption

Insert a new GUID to Visual Studio 2012

匿名 (未验证) 提交于 2019-12-03 02:44:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Is it possible to create a code snippet or something similar to automate the process of generating and inserting GUIDs in to the text editor in Visual Studio 2012? I frequently need to generate new GUIDs (WiX installer for example, as well as our own internal framework). I used to use a macro to perform this job, creating a new GUID and then inserting it in to the current ActiveDocument. I would the bind the macro to Shift-Ctrl G so I could rapidly insert a new ID without having to launch the Create Guid tool and copy from there. Macro

NewGuid vs System.Guid.NewGuid().ToString(“D”);

橙三吉。 提交于 2019-12-03 02:42:51
问题 Is there a difference when you generate a GUID using NewGuid(); vs System.Guid.NewGuid().ToString("D"); or they are the same thing? 回答1: Guid.NewGuid().ToString() is string representation of GUID, i.e. returns string object, while Guid.NewGuid() returns Guid datatype. 回答2: I realize that this question already has an accepted answer, but I thought it would be useful to share some information about formatting guids. The ToString() (no parameters) method formats a guid using this format:

Using Parts of GUID as ID

匿名 (未验证) 提交于 2019-12-03 02:30:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm developing an ASP .Net MVC application. One of my actions requires id as a parameter. For example: public actionresult Detail(Guid id){ return View(); } As you can see, I'm using Guid instead of Int . The issue is more cosmetic. The url can be very long, such as localhost/Detail/0c157b42-379d-41d5-b9ba-83e9df9985b2 . Is it safe to take only parts of the Guid like localhost/Detail/0c157b42 ? 回答1: GUID is designed in such a way that it is intended to be unique, but any part of it is not. See this blog post for details. If you need to