guid

Guid Byte Order in .NET

删除回忆录丶 提交于 2019-11-27 05:55:17
问题 I am creating a GUID like this Guid g = new Guid(new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xA, 0xB, 0xC, 0xD, 0xE, 0xF }); Console.WriteLine(g); This outputs 03020100-0504-0706-0809-0a0b0c0d0e0f According to Wikipedia there are four parts in the guid and this explains why the bytes order switch in four groups. However the Wikipedia article also states that all parts are stored in Big Endian format. Obviously the first three parts are not Big Endian. The GetBytes() method of the guid returns

What is the string length of a GUID?

那年仲夏 提交于 2019-11-27 05:51:59
I want to create a varchar column in SQL that should contain N'guid' while guid is a generated GUID by .NET ( Guid.NewGuid ) - class System.Guid. What is the length of the varchar I should expect from a GUID? Is it a static length? Should I use nvarchar (will GUID ever use Unicode characters)? varchar(Guid.Length) PS. I don't want to use a SQL row guid data-type. I am just asking what is Guid.MaxLength . It depends on how you format the Guid: Guid.NewGuid().ToString() => 36 characters (Hyphenated) outputs: 12345678-1234-1234-1234-123456789abc Guid.NewGuid().ToString("D") => 36 characters

UUID format: 8-4-4-4-12 - Why?

无人久伴 提交于 2019-11-27 05:31:46
问题 Why are UUID's presented in the format "8-4-4-4-12" (digits)? I've had a look around for the reason but can't find the decision that calls for it. Example of UUID formatted as hex string: 58D5E212-165B-4CA0-909B-C86B9CEE0111 回答1: It's separated by time, version, clock_seq_hi, clock_seq_lo, node , as indicated in the followoing rfc. From the IETF RFC4122: 4.1.2. Layout and Byte Order To minimize confusion about bit assignments within octets, the UUID record definition is defined only in terms

大文件+断点续传

吃可爱长大的小学妹 提交于 2019-11-27 04:46:14
前段时间做视频上传业务,通过网页上传视频到服务器。 视频大小 小则几十M,大则 1G+,以一般的HTTP请求发送数据的方式的话,会遇到的问题:1,文件过大,超出服务端的请求大小限制;2,请求时间过长,请求超时;3,传输中断,必须重新上传导致前功尽弃; 解决方案: 1,修改服务端上传的限制配置;Nginx 以及 PHP 的上传文件限制 不宜过大,一般5M 左右为好; 2,大文件分片,一片一片的传到服务端,再由服务端合并。这么做的好处在于一旦上传失败只是损失一个分片而已,不用整个文件重传,而且每个分片的大小可以控制在4MB以内,服务端限制在4M即可。 前端 Web前端可使用HttpUploader6的大文件上传控件6;官网地址: http://t.cn/EyI6vHh <div class="section section6 section5"> <div class="part1"><a href="javascript:;" target="_blank" class="part1__btn">批量删除</a><span class="part1__txt"><em class="part1__num" id="upload_num">0</em>个视频,共 <em class="part1__num" id="upload_size">0M</em></span></div>

How to read a .NET Guid into a Java UUID

别等时光非礼了梦想. 提交于 2019-11-27 04:37:23
I need to communicate a Guid that was generated in .NET to a Java application. I use Guid.ToByteArray() to store it on disk as a byte[] , then read it into Java and convert it to a UUID. For this purpose I copied the implementation of the (private) constructor of UUID that takes a byte[] : private UUID(byte[] data) { long msb = 0; long lsb = 0; assert data.length == 16; for (int i=0; i<8; i++) msb = (msb << 8) | (data[i] & 0xff); for (int i=8; i<16; i++) lsb = (lsb << 8) | (data[i] & 0xff); this.mostSigBits = msb; this.leastSigBits = lsb; } However, when I inspect the UUID using toString() ,

What is the correct way of using the Guid type in a XSD file?

霸气de小男生 提交于 2019-11-27 04:27:50
问题 I have a .xsd file which I use to generate code with the xsd.exe tool from Visual Studio. Some class members are Guids and the xsd.exe tool gives 2 warnings: Namespace 'http://microsoft.com/wsdl/types/' is not available to be referenced in this schema. Type 'http://microsoft.com/wsdl/types/:guid' is not declared. The Guid type is recognized because the generated C# file is valid and works. Anyone knows how to get rid of those warnings? What is the correct syntax for the XSD to be validated

Why are there dashes in a .NET GUID?

扶醉桌前 提交于 2019-11-27 04:22:50
问题 Why are there dashes in a .NET GUID? Are there dashes in most implementations of a GUID, or is it just a Microsoft thing? Signed, 741ecf77-9c92-4435-8e6b-85975bd13452 回答1: Technically, there are no "dashes" in a GUID. A GUID is a 128-bit value which is usually stored in the following manner (using C# here to represent the structure): public struct Guid { public ulong Data1; public ushort Data2; public ushort Data3; public fixed byte Data4[8]; } The dashes are in the string representation of a

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

二次信任 提交于 2019-11-27 04:20:58
When you call ToByteArray() on a GUID in .NET, the ordering of the bytes in the resulting array is not what you'd expect as compared to the string representation of the GUID. For example, for the following GUID represented as a string: 11223344-5566-7788-9900-aabbccddeeff The result of ToByteArray() is this: 44, 33, 22, 11, 66, 55, 88, 77, 99, 00, AA, BB, CC, DD, EE, FF Note that the order of the first four bytes is reversed. Also bytes 4 and 5 are swapped and bytes 6 and 7 are swapped. But the final 8 bytes are in the same order they're represented as in the string. I understand that this is

A TypeScript GUID class? [closed]

南楼画角 提交于 2019-11-27 04:20:29
Does anyone know of a good, solid, implementation of C# like GUID (UUID) in TypeScript? Could do it myself but figured I'd spare my time if someone else done it before. Fenton There is an implementation in my TypeScript utilities based on JavaScript GUID generators. Here is the code: class Guid { static newGuid() { return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8); return v.toString(16); }); } } // Example of a bunch of GUIDs for (var i = 0; i < 100; i++) { var id = Guid.newGuid(); console.log(id); }

Storing MySQL GUID/UUIDs

本小妞迷上赌 提交于 2019-11-27 04:13:30
问题 This is the best way I could come up with to convert a MySQL GUID/UUID generated by UUID() to a binary(16): UNHEX(REPLACE(UUID(),'-','')) And then storing it in a BINARY(16) Are there any implications of doing it this way that I should know of? 回答1: Not many implications. It will slow down the queries a little, but you will hardly notice it. UNIQUEIDENTIFIER is stored as 16-byte binary internally anyway. If you are going to load the binary into a client and parse it there, note the bit order