I'm having trouble imagining who would want to use this. What's the environment where you would have curl and a need for generating UUIDs, but wouldn't have access to uuidgen or similar?
Yeah, I'm just really confused. If you're at a CLI, you probably have uuidgen. And I'd assume there's something similar on Windows.
If you're writing some kind of application, pretty much every language/framework can generate UUIDs, and even if yours doesn't, just generate a 128-bit number, stamp the v4 UUID bits into it, reformat it, and you're done. Calling out to a 3rd-party service is insane for that use case anyway.
Understandable! I made it for the few times I'm manually testing an API using Swagger or something similar and need a valid(ish) GUID to stand in for some field being sent to the api.
There's no shortage of ways to generate GUIDs, that's for sure!
Maybe a JS App which is made completely out of third party APIs, without anything self-hosted? Not discussing wether this is a good idea or not, though...
I was surprised to see that there is no "built-in" mechanism in JS to generate a GUID. As a C# dev, I'm used to Guid.NewGuid()
Is this just a "random" UUID or does it meet specs of RFC 4122? I have seen countless times when it was just generated as {8}-{4}-{4}-{4}-{12} with complete random numbers. Well, works for most applications...
This is what I use to generate guids with autohotkey:
::;guid::
guid := GUID()
StringLower, guid, guid
Clipboard := guid
SendInput,^v
return
GUID()
{
format = %A_FormatInteger% ; save original integer format
SetFormat Integer, Hex ; for converting bytes to hex
VarSetCapacity(A,16)
DllCall("rpcrt4\UuidCreate","Str",A)
Address := &A
Loop 16
{
x := 256 + *Address ; get byte in hex, set 17th bit
StringTrimLeft x, x, 3 ; remove 0x1
h = %x%%h% ; in memory: LS byte first
Address++
}
SetFormat Integer, %format% ; restore original format
h := SubStr(h,1,8) . "-" . SubStr(h,9,4) . "-" . SubStr(h,13,4) . "-" . SubStr(h,17,4) . "-" . SubStr(h,21,12)
return h
}
I remember several years ago using https://newguid.com which was pretty much the same thing - no page furniture, just the new guid. Sadly the domain seems to be on sale now!
Why would you want to hash random bytes? The only thing you could theoretically achieve by that would be decreasing entropy. Just do openssl rand -hex 20 (or any other number of bytes as needed, or -base64 for another encoding).
tkfu|5 years ago
kelnos|5 years ago
If you're writing some kind of application, pretty much every language/framework can generate UUIDs, and even if yours doesn't, just generate a 128-bit number, stamp the v4 UUID bits into it, reformat it, and you're done. Calling out to a 3rd-party service is insane for that use case anyway.
deweyair|5 years ago
There's no shortage of ways to generate GUIDs, that's for sure!
p4bl0|5 years ago
MrGilbert|5 years ago
I was surprised to see that there is no "built-in" mechanism in JS to generate a GUID. As a C# dev, I'm used to Guid.NewGuid()
fyfy18|5 years ago
speedgoose|5 years ago
cat /proc/sys/kernel/random/uuid
aranw|5 years ago
cat: /proc/sys/kernel/random/uuid: No such file or directory
shean_massey|5 years ago
raxxorrax|5 years ago
queuep|5 years ago
GUID() { format = %A_FormatInteger% ; save original integer format SetFormat Integer, Hex ; for converting bytes to hex VarSetCapacity(A,16) DllCall("rpcrt4\UuidCreate","Str",A) Address := &A Loop 16 { x := 256 + *Address ; get byte in hex, set 17th bit StringTrimLeft x, x, 3 ; remove 0x1 h = %x%%h% ; in memory: LS byte first Address++ } SetFormat Integer, %format% ; restore original format h := SubStr(h,1,8) . "-" . SubStr(h,9,4) . "-" . SubStr(h,13,4) . "-" . SubStr(h,17,4) . "-" . SubStr(h,21,12) return h }
GoblinSlayer|5 years ago
huhtenberg|5 years ago
politelemon|5 years ago
There's also https://www.newguid.org/
berkes|5 years ago
Which is a perfect example why it is bad to rely on a service like this to generate your IDs.
What if I bought it and started emitting predictable IDs? Or non-unique IDs?
unknown|5 years ago
[deleted]
patricjansson|5 years ago
deweyair|5 years ago
aranw|5 years ago
I use the following alias to generate uuids
I then pair it with pbcopy on the macjcelerier|5 years ago
deweyair|5 years ago
nonoesp|5 years ago
- https://www.givemeguid.com/?number=5
plasma|5 years ago
deweyair|5 years ago
aloisdg|5 years ago
thinkingkong|5 years ago
uuidgen is one. My personal favorite is this snippet.
$ id=$(openssl rand 1000 | openssl sha1) && printf "%s${id:0:8}\n"
mormegil|5 years ago
santiagobasulto|5 years ago
redact207|5 years ago
antiufo|5 years ago
Jaruzel|5 years ago
eterm|5 years ago
Is shorter and easier.
unknown|5 years ago
[deleted]