Unix 和 Windows 的命令行 GUID?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/569858/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Command line GUID for Unix and Windows?
提问by Robert Gould
回答by gavenkoa
'e2fsprogs' project maintain uuidgenutility.
'e2fsprogs' 项目维护uuidgen实用程序。
http://e2fsprogs.sourceforge.net/
http://e2fsprogs.sourceforge.net/
It is already available on any Linux/BSD* distros.
它已经在任何 Linux/BSD* 发行版上可用。
For Windows I recommend install Cygwin, 'e2fsprogs' package available from there!
对于 Windows,我建议安装 Cygwin,可以从那里获得“e2fsprogs”包!
As report j4ythis utility is available under MAC OS.
作为报告j4y,此实用程序可在 MAC OS 下使用。
Just run:
赶紧跑:
$ uuidgen -r # random based UUID/GUID $ uuidgen -t # time based UUID/GUID
回答by Dirk Vollmar
I don't know if there is a command line tool available, but you could simply write one in C# (it should run with Mono):
我不知道是否有可用的命令行工具,但您可以简单地用 C# 编写一个(它应该与 Mono 一起运行):
class Program
{
static void Main(string[] args)
{
Console.WriteLine(System.Guid.NewGuid().ToString());
}
}
You can easily modify the program to change formatting of the GUID, copy it to the clipboard or whatever fits your need.
您可以轻松修改程序以更改 GUID 的格式、将其复制到剪贴板或任何适合您的需要。
回答by crb
Something useful to know:
一些有用的知识:
The byte order of Guid.ToByteArray() in C# and the SQL Server GUID type is:
C#中 Guid.ToByteArray() 的字节顺序和 SQL Server GUID 类型为:
{ 3, 2, 1, 0, 5, 4, 7, 6, 8, 9, 10, 11, 12, 13, 14, 15 };
An Oracle GUID created using SYS_GUID() and stored as RAW[16] is ordered:
使用 SYS_GUID() 创建并存储为 RAW[16] 的 Oracle GUID 被排序:
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
You may find this online GUID converterhandy. I'm not sure if the source is available for your own use, but it shouldn't be too hard to figure it out.
您可能会发现这个在线 GUID 转换器很方便。我不确定该源是否可供您自己使用,但弄清楚它应该不会太难。
回答by anagels
In Windows XP, you can use the following in the command window.
在 Windows XP 中,您可以在命令窗口中使用以下命令。
uuidgen.exe
回答by T.E.D.
There are tons of online appsto do it.
有大量的在线应用程序可以做到这一点。
If you are using PHP, you can use the uniqid function.
如果您使用的是 PHP,则可以使用 uniqid 函数。
I found a pure Java program to do it at http://jug.safehaus.org/. That should work anywhere you can install Java.
我在http://jug.safehaus.org/找到了一个纯 Java 程序来完成它。这应该适用于您可以安装 Java 的任何地方。