guid

base64 to guid to base64

拈花ヽ惹草 提交于 2019-12-04 09:36:29
I'm currently researching MongoDb as a possible database option, and I'm having trouble dealing with Guid serialization. I thought at first maybe this was a bug in the C# driver's serialization, but now I think it's more likely a naive assumption on my part. To help me convert the Bson base64 representations back and forth to Guids, I wrote a couple of little powershell functions to help: function base64toguid { param($str); $b = [System.Convert]::FromBase64String($str); $hex = ""; foreach ($x in $b) { $hex += $x.ToString("x2"); } $g = new-object -TypeName System.Guid -ArgumentList $hex;

SQL Server database with clustered GUID PKs - switch clustered index or switch to sequential (comb) GUIDs?

泄露秘密 提交于 2019-12-04 08:34:50
We have a database in which all the PKs are GUIDs, and most of the PKs are also the clustered index for the table. We know that this is bad (due to the random nature of GUIDs). So, it seems there are basically two options here (short of throwing out GUIDs as PKs altogether, which we cannot do (at least not at this time)). We could change the GUID generation algorithm to e.g. the one that NHibernate uses, as detailed in this post , or we could, for the tables that are under the heaviest use, change to a different clustered index, e.g. an IDENTITY column, and keep the "random" GUIDs as PKs. Is

SQL Server: Search all tables for a particular GUID

≯℡__Kan透↙ 提交于 2019-12-04 06:26:10
问题 i came across the need to cleanse some data, and i need to find some particular guids (i.e. uniqueidentifiers ) in SQL Server°. i've come up with a stored procedure that does a SELECT from every uniqueidentifier column in every table in the current database, and returns a result set if the guid is found. It uses the INFORMATION_SCHEMA views to find all uniqueidentifier columns in all base tables (as opposed to views). For each column it issues a select, returning the name of the table and the

GUIDs in a C++ Linux GCC app

折月煮酒 提交于 2019-12-04 06:16:47
I've got a bunch of servers running this Linux app. I'd like for them to be able to generate a GUID with a low probability of collision. I'm sure I could just pull 128 bytes out of /dev/urandom and that would probably be fine, but is there a simple & easy way to generate a GUID that is more equivalent to the Win32 one? Specifically, one that takes into account space (well, MAC address), time, and randomness? I don't want to call off the box for it, I just want something like CreateGuid() This Internet Draft describes one type of UUID in great details and I have used a similar approach with

Creating a Globally Unique Android Identifier

纵饮孤独 提交于 2019-12-04 05:53:38
When talking about unique Android ID's, I'm sure everyone has seen this , however I too am trying to come up with a solution to uniquely identify any android device. I would be happy to use a publicly released class but I am yet to find one. In my situation, the requirement is to be able to uniquely identify any devices that have some form of an internet connection (such as GPRS or Wi-Fi) and run on API level 8 (v2.2 Froyo). I'm not aware of any devices that doesn't have Wi-Fi or a SIM so let me know if there is any! We solved this problem in iOS by using a hash of the Wi-Fi mac address as all

如何在高并发分布式系统中生成全局唯一ID

筅森魡賤 提交于 2019-12-04 05:41:52
最近公司用到,并且在找最合适的方案,希望大家多参与讨论和提出新方案。我和我的小伙伴们也讨论了这个主题,我受益匪浅啊…… 博文示例: GUID生成Int64值后是否还具有唯一性测试 Random生成高唯一性随机码 今天分享的主题是:如何在高并发分布式系统中生成全局唯一Id。 但这篇博文实际上是“半分享半讨论”的博文: 1) 半分享是我将说下我所了解到的关于今天主题所涉及的几种方案。 2) 半讨论是我希望大家对各个方案都说说自己的见解,更加希望大家能提出更好的方案。(我还另外提问在此: http://q.cnblogs.com/q/53552/ ) 我了解的方案如下…………………………………………………………………… 1、 使用数据库自增Id 优势:编码简单,无需考虑记录唯一标识的问题。 缺陷: 1) 在大表做水平分表时,就不能使用自增Id,因为Insert的记录插入到哪个分表依分表规则判定决定,若是自增Id,各个分表中Id各自增长就会重复 2) 在业务上操作父、子表(即关联表)插入时,需要在插入数据库 之前 获取max(id)用于标识父表和子表关系,若存在并发获取max(id)的情况,max(id)会同时被别的线程获取到。 3) DB数据记录都是可以根据ID号进行推测出来,对于一些数据敏感的场景,不建议采用 结论:适合小应用,无需分表,低并发。 2、 单独开一个数据库

Why does aspnet_users use guid for id rather than incrementing int? bonus points for help on extending user fields

倖福魔咒の 提交于 2019-12-04 05:32:33
Why does aspnet_users use guid for id rather than incrementing int? Also is there any reason no to use this in other tables as the primary key? It feels a bit odd as I know most apps I've worked with in the past just use the normal int system. I'm also about to start using this id to match against an extended details table for extra user prefs etc. I was also considering using a link table with a guid and an int in it, but decided that as I don't think I actually need to have user id as a public int. Although I would like to have the int (feels easier to do a user lookup etc stackoverflow.com

Securing AJAX Requests via GUID

与世无争的帅哥 提交于 2019-12-04 05:18:46
I'm writing a web app that will be making requests via AJAX and would like to lock down those calls. After a little research, I am considering using some form of random token (string) to be passed back along with the request (GUID?). Here's the important parts of my algorithm: Assign a token to a JavaScript variable (generated server-side). Also, store that token in a DB and give it a valid time period (i.e. 10 minutes). If the token has still not been used and is within it's valid time window, allow the call. Return requested information if valid, otherwise, log the request and ignore it.

Using Parts of GUID as ID

泄露秘密 提交于 2019-12-04 03:26:57
问题 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.

Using both a GUID and an auto-incrementing integer

霸气de小男生 提交于 2019-12-04 03:21:58
I've been investigating the use of GUIDs as primary keys in databases. So far, the pros seem to outweigh the cons. However, I see one point where GUIDs may not be what I want. In my application, users should be able to identify objects based on a user-friendly ID. So, for example, if they want to get a specific product without typing in the full name, they can use the product's ID. GUIDs aren't easy to remember for something like that. The solution I've been thinking about is to use both a GUID and an auto-incrementing integer. The GUID would be the row's primary key, while the auto