Git Product home page Git Product logo

shortuuid's Introduction

Description

shortuuid is a simple python library that generates concise, unambiguous, URL-safe UUIDs.

Often, one needs to use non-sequential IDs in places where users will see them, but the IDs must be as concise and easy to use as possible. shortuuid solves this problem by generating uuids using Python's built-in uuid module and then translating them to base57 using lowercase and uppercase letters and digits, and removing similar-looking characters such as l, 1, I, O and 0.

image

Installation

To install shortuuid you need:

  • Python 3.6+

If you have the dependencies, you have multiple options of installation:

Usage

To use shortuuid, just import it in your project like so:

>>> import shortuuid

You can then generate a short UUID:

>>> shortuuid.uuid()
'vytxeTZskVKR7C7WgdSP3d'

If you prefer a version 5 UUID, you can pass a name (DNS or URL) to the call and it will be used as a namespace (uuid.NAMESPACE_DNS or uuid.NAMESPACE_URL) for the resulting UUID:

>>> shortuuid.uuid(name="example.com")
'exu3DTbj2ncsn9tLdLWspw'

>>> shortuuid.uuid(name="<http://example.com>")
'shortuuid.uuid(name="<http://example.com>")'

You can also generate a cryptographically secure random string (using os.urandom() internally) with:

>>> shortuuid.ShortUUID().random(length=22)
'RaF56o2r58hTKT7AYS9doj'

To see the alphabet that is being used to generate new UUIDs:

>>> shortuuid.get_alphabet()
'23456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'

If you want to use your own alphabet to generate UUIDs, use set_alphabet():

>>> shortuuid.set_alphabet("aaaaabcdefgh1230123")
>>> shortuuid.uuid()
'0agee20aa1hehebcagddhedddc0d2chhab3b'

The default alphabet matches the regex [2-9A-HJ-NP-Za-km-z]{22}.

shortuuid will automatically sort and remove duplicates from your alphabet to ensure consistency:

>>> shortuuid.get_alphabet()
'0123abcdefgh'

If the default 22 digits are too long for you, you can get shorter IDs by just truncating the string to the desired length. The IDs won't be universally unique any longer, but the probability of a collision will still be very low.

To serialize existing UUIDs, use encode() and decode():

>>> import uuid
>>> u = uuid.uuid4()
>>> u
UUID('6ca4f0f8-2508-4bac-b8f1-5d1e3da2247a')

>>> s = shortuuid.encode(u)
>>> s
'MLpZDiEXM4VsUryR9oE8uc'

>>> shortuuid.decode(s) == u
True

>>> short = s[:7]
>>> short
'MLpZDiE'

>>> h = shortuuid.decode(short)
UUID('00000000-0000-0000-0000-009a5b27f8b9')

>>> shortuuid.decode(shortuuid.encode(h)) == h
True

Class-based usage

If you need to have various alphabets per-thread, you can use the ShortUUID class, like so:

>>> su = shortuuid.ShortUUID(alphabet="01345678")
>>> su.uuid()
'034636353306816784480643806546503818874456'

>>> su.get_alphabet()
'01345678'

>>> su.set_alphabet("21345687654123456")
>>> su.get_alphabet()
'12345678'

Command-line usage

shortuuid provides a simple way to generate a short UUID in a terminal:

$ shortuuid
fZpeF6gcskHbSpTgpQCkcJ

Django field

shortuuid includes a Django field that generates random short UUIDs by default, for your convenience:

from shortuuid.django_fields import ShortUUIDField

class MyModel(models.Model):
    # A primary key ID of length 16 and a short alphabet.
    id = ShortUUIDField(
        length=16,
        max_length=40,
        prefix="id_",
        alphabet="abcdefg1234",
        primary_key=True,
    )

    # A short UUID of length 22 and the default alphabet.
    api_key = ShortUUIDField()

The field is the same as the CharField, with a length argument (the length of the ID), an alphabet argument, and the default argument removed. Everything else is exactly the same, e.g. index, help_text, max_length, etc.

Compatibility note

Versions of ShortUUID prior to 1.0.0 generated UUIDs with their MSB last, i.e. reversed. This was later fixed, but if you have some UUIDs stored as a string with the old method, you need to pass legacy=True to decode() when converting your strings back to UUIDs.

That option will go away in the future, so you will want to convert your UUIDs to strings using the new method. This can be done like so:

>>> new_uuid_str = encode(decode(old_uuid_str, legacy=True))

License

shortuuid is distributed under the BSD license.

shortuuid's People

Contributors

asellappen avatar bollwyvl avatar cewood avatar cjwatson avatar coagulant avatar croby avatar demoray avatar ecederstrand avatar ekamil avatar fengsi avatar grantjenks avatar hhartzer avatar ivanistheone avatar jleclanche avatar keanemind avatar kevinastone avatar kolanich avatar lehrblogger avatar mkouhei avatar mrjbq7 avatar nikolas avatar pavelzw avatar pcolladosoto avatar polastre avatar sebastibe avatar skorokithakis avatar spaceshaman avatar tcrothers avatar tirkarthi avatar xadrianzetx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

shortuuid's Issues

Request to update format of license in pyproject.toml

Hello!

I want to start by saying thank you for such a great python module and for making it available for everyone to use.

Looking at the license of this module on pypi.org it does not seem to match the actual license included in here:
https://github.com/skorokithakis/shortuuid/blob/master/COPYING

Could you please update this file:
https://github.com/skorokithakis/shortuuid/blob/master/pyproject.toml#L5

to accurately reflect the license?

I believe the line needs to be the following:
license = License :: OSI Approved :: BSD License

It would be greatly appreciated as it seems the current state of things reflects your desired license incorrectly and this can prevent it from being scanned successfully by some auditing tools out there.

If you would prefer me to create a PR for this, I would be happy to oblige.

Thanks!

LSB-first encoding makes lexicographic ordering hard

Let's say I want to group a number of shortuuids into several non-overlapping partitions and use a string-based comparison that defines each partition, e.g. "aaa" <= shortuuid < "bbb". Since shortuuids are LSB-first, this isn't possible, since 0 corresponds to '2222222222222222222222' and 1 corresponds to '3222222222222222222222'. With UUIDs generated with str(uuid.uuid4()) this would be '00000000-0000-0000-0000-000000000000' for 0 and '00000000-0000-0000-0000-000000000001' for 1, which is useable for lexicographic ordering based on their integer representation.
Is there a specific reason why shortuuids are LSB-first? In my case it complicates things, but are there advantages I'm ignoring?

shortuuid performance and sorting

I was playing with our Java UUID shortner I wrote several years ago and I decided to see what other folks are doing and came across library.

Anyway I have few critiques.

The algorithm as I understand turns the UUID into one giant 128 bit integer and divmods appending the remainder to a string. The most significant part of the UUID is appended first but the contents of the most significant has the most significant right most. For example base10 a "100" would be 001 or in base57 m3.

There are two problems to this approach:

  • Sorting is no longer the same. That is if you have a list of UUIDs and list of corresponding shortuuids the sort order will not be same. This is because it follows the bit order which makes since for a generic encoding algorithm but I don't think its good for a UUID shortner.
  • The algorithm is very slow on Java. Or at least this implementation which appears to be a clone of the golang https://github.com/hsingh/java-shortuuid and mostly follows the python version.

An easy replacement for the Java one is to use Bitcoin's Base58 and just change the alphabet which is originally what I used to use for UUID shortening. However Base58 divmods byte by byte and does not construct a full 128 bit integer.

Still Base58 is actually still not that fast compared to say Base64 and that is obviously because of power of 2 division.

My algorithm is almost as fast as base 64.
My algorithm works by divmoding longs (64 bit numbers in java) one at a time. This is fine because a UUID is two 64 bit numbers. Secondly there are tricks divmoding 64 bit numbers super fast even if they are not powers of 2 divisors.
Secondly it appends the most significant left to write to preserve lexicographical sort order. Padding is required but based on my tests only like ~2% of UUIDs have less than 22 characters (I was too lazy to do the math).

Anyway before I go set an opensource repository and try to port it to python I wanted to get some feedback. Is this a bad idea?

Why base57?

Use string concatenation to improve performance.

Not a bug, but a suggestion: String concatenation is quite fast since Python 2.5. In most cases, the dot-lookup and method call in list.append() is more expensive than string += string.

>>> test_list = '''
... output=[]
... for char in data:
...   output.append(char)
... "".join(output)
... '''
>>> min(timeit.repeat(test_list, 'data="abcdefghijklnopqrstuvwxyz"*10'))
71.001188039779663
>>> test_str = '''
... output=''
... for char in data:
...   output += char
... output
... '''
>>> min(timeit.repeat(test_str, 'data="abcdefghijklnopqrstuvwxyz"*10'))
43.843056917190552

Please include type hints

I'm happy to help write the type hints but I'm not sure how it would work with Python versions 3.0-3.4.

Question about compatibility

Hi, in README says that is compatible with python 2.X , but I tried it in an environment with python 3 and seems to work.
I am not trying it ok? or its working with python 3.X ?

Duplicated shord uuid

I'm using shortuuid.ShortUUID().random(length=22) for generating short-uuids in a django application on Heroku.

In already 2 cases I found a duplicated uuid. I haven't been able to reproduce whenever I want the error yet.

Using this as default in SQLAlchemy Column generates duplicates

I have a flask project I am working on and noticed that I was consistently generating duplicates on both mac and linux when saving a record and using shortuuid.uuid() as the default value in the column:

For example:

class Post(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    post_code = db.Column(db.String(30), default=shortuuid.uuid())

I seemed to have solved the issue by forcing unique on the database level and then creating the shortuuid.uuid() explicitly when creating a model (instead of leaving it blank)
What I mean is this would generate duplicates:

p = Post()
db.session.add(p)
db.session.commit()

but this is not generating duplicates (so far)

code = shortuuid.uuid()
p = Post(post_code=code)
db.session.add(p)
db.session.commit()

Just curious if there is any information on this

Move _num_to_string to be a global function?

It's a useful function, would be nice being able to use it without instanciating a shortuuid :)

My use case: I'm converting a md5 (from another source) to a shortuuid.

shortuuid.ShortUUID()._num_to_string(int("d41d8cd98f00b204e9800998ecf8427e", 16))

Python 3 release

Could you do a PyPI release that includes the recently-added Python 3 support please? Thanks!

Feature request: ShortUUIDField for Django models

It would be nice to have ShortUUIDField which is a subclass of Django's UUIDField that uses UUIDs internally, but show sortuuids to users.

I have some WIP code that implements this:

A usage example:

class Node(models.Model):
    id = ShortUUIDField(primary_key=True, prefix='N', length=7)
    ...

which will create shortcodes of length at most 7, and each id will start with prefix N.

It was kind of tricky to add tests for this:

I realize the defaults (truncation to length=7 and prefix) in the code samples might not be suitable for general use, so not going to open a PR yet. I'm going to keep using this for the specific application an possibly followup with a PR in January 2021 if you think this would be worth adding to this repo.

Opening this issue to keep the links together and so I'll remember to get back to this.

setup.py interprets python 3.10 as python 3.1

sys.version returns "3.10" and comparing it with "3.5" will take it as "3.1" and return false. Using sys.version_info is a better way to check for version. Fedora bug : https://bugzilla.redhat.com/show_bug.cgi?id=1900743

~/cpython/python
Python 3.10.0a5+ (heads/master:cd80f430da, Feb 17 2021, 14:08:19) 
[GCC 7.5.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.version
'3.10.0a5+ (heads/master:cd80f430da, Feb 17 2021, 14:08:19) \n[GCC 7.5.0]'
>>> sys.version >= "3.5"
False

assert sys.version >= "3.5", "Requires Python v3.5 or above."

ShortUUID should not sort the alphabet

I am attempting to convert a shortuuid generated using node.js and the Flicker base 58 alphabet:

shortid = 'apECAPA6RdHB6HB51FwsdN'
FLICKR_BASE58 = '123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ'
uuid = shortuuid.ShortUUID(alphabet=FLICKR_BASE58).decode(shortid)

Unfortunately this doesn't work:

Traceback (most recent call last):
  File "<ipython-input-54-88d3ac3dd885>", line 3, in <module>
    uuid = shortuuid.ShortUUID(alphabet=FLICKR_BASE58).decode(shortid)
  File "/Users/scotts/.pyenv/versions/python38/lib/python3.8/site-packages/shortuuid/main.py", line 79, in decode
    return _uu.UUID(int=string_to_int(string, self._alphabet))
  File "/Users/scotts/.pyenv/versions/3.8.7/lib/python3.8/uuid.py", line 205, in __init__
    raise ValueError('int is out of range (need a 128-bit value)')
ValueError: int is out of range (need a 128-bit value)

It turns out that ShortUUID is sorting the alphabet before using it. This is incorrect and leads to this failure. It is possible to correctly decode the id like this:

import uuid as _uu
uuid = _uu.UUID(int=string_to_int(shortid, FLICKR_BASE58))

This is a backwards compatibility issue, so switching to an unsorted implementation will probably require a compatibility flag similar to legacy.

shortuuid examples on the readme are old format

>>> import uuid
>>> u = uuid.uuid4()
>>> u
UUID('6ca4f0f8-2508-4bac-b8f1-5d1e3da2247a')

>>> s = shortuuid.encode(u)
>>> s
'cu8Eo9RyrUsV4MXEiDZpLM'

Is no longer correct. When I was verifying that Java version I used that example. You should probably change it (the string is just in reverse).

BTW I had no idea of the format change hence most of my confusion #69

Values generated by `shortuuid.random` are often invalid

Repro:

>>> import shortuuid
>>> while True: shortuuid.decode(shortuuid.random())
...
UUID('0b01b8fa-55db-37eb-95b4-5e8a5bb7de08')
UUID('06643955-e965-2c48-5317-a2a7185707d6')
UUID('0a714dc4-a310-7053-b6db-db117cd3db72')
UUID('5cfd332a-a814-87d7-bdb6-4594c587046c')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/rijenkii/.local/lib/python3.10/site-packages/shortuuid/main.py", line 79, in decode
    return _uu.UUID(int=string_to_int(string, self._alphabet))
  File "/usr/lib/python3.10/uuid.py", line 211, in __init__
    raise ValueError('int is out of range (need a 128-bit value)')
ValueError: int is out of range (need a 128-bit value)

Add simple command-line interface

Hello! Thanks for this lib, it’s really useful to generate unique IDs painlessly.

Often I want to generate a bunch of values, for example to define object IDs in test fixtures. It’s easy enough to open a Python shell to do that, but would be even easier with a command-line interface 🙂

Simplest version:

# add shortuuid/__main__.py
from .main import uuid

if __name__ == "__main__":
    print(uuid())
$ python -m shortuuid
QG6wVwX8X4kqy829JE9zLT

Featureful version: add params to control length [*] and number of IDs to generate.

*: I’m not sure if this should use ShortUUID.random or uuid+truncate

DataError: invalid input syntax for type uuid

Django Version: | 4.0.1
Exception Type: DataError
Exception Value: invalid input syntax for type uuid: "HxXrBSybVoBjkXif" LINE 1: ...ES ('820008d1-b486-480b-92ec-accf5e722ef8'::uuid, 'HxXrBSybV...

So I had a Django model field that was a UUIDField and I want to migrate it to a ShortUUIDField like this:

Before

    id = models.UUIDField(
         primary_key=True, default=uuid.uuid4, editable=False)

After

    id = ShortUUIDField(
        length=16,
        max_length=40,
        primary_key=True,
    )

The makemigrations and migrate commands ran just fine. But when I try to create an instance of the object I get the above error in the Django admin console.
I haven't found anything on stackoverflow about this. Am I missing a step?
Also, sorry if this is not the right place for this question.

Edge case when serializing UUID(int=0) with pad_length=0

I'm using truncated shortuuid and encoding them with pad_length=0 to avoid the leading 2s (first char of alphabet).

It's working great overall (roundtrip encoding and decoding), except for the edge case of encoding uuid.UUID('00000000-0000-0000-0000-000000000000') which ends up as empty string:

>>> shortuuid.encode( uuid.UUID('00000000-0000-0000-0000-000000000000'), pad_length=0)
''  # empty str

This is not a bug and technically correct output, however it causes some problems in practice since other code treats this as falsy, and cannot be displayed as a link text since nothing to click on.

Perhaps we should make an exception in this case and treat it as pad_lenght=1 to return '2' as the code?
This way we can get back to full round trip:

>>> shortuuid.decode('2')
UUID('00000000-0000-0000-0000-000000000000')

Unclear how to use UUID5, namespace

My understanding of UUID v5 is you can provide a namespace and a value to get a deterministic hash for that namespace + value.

I see you can provide shortuuid.uuid a name argument, and I see in the code how that maps to uuid5 in the code... but it's unclear to me what to do from there.

I see that providing the same name argument produces the same output (as expected!). How do you now combine a namespace and value to get a deterministic output, such that func(namespace, value) produces the same output every time (where namespace remains the same and value changes)?

Perhaps I'm misunderstanding something. Thanks.

README not that complete

Hi,
I am trying to parse a url and short with shortuuid but i cant find anything in the README that explains how to do that.
I did shortuuid.uuid(name="www.google.pt") but how can i go to www.google.pt using the uuid that i get?

Thanks

please tag releases and include release notes

Just noticed there was a new release of shortuuid. Looked for a CHANGELOG under https://pypi.python.org/pypi/shortuuid and https://github.com/stochastic-technologies/shortuuid/ but didn't find one. Went to https://github.com/stochastic-technologies/shortuuid/releases in hopes of seeing this info there, but came up empty since you're not tagging releases. Would you consider tagging releases and adding release notes? In the meantime, users have to comb through e.g. https://github.com/stochastic-technologies/shortuuid/commits/develop to try to tease out what's changed when there's a new release.

Thanks for the great work on shortuuid.

deprecation warning in set_alphabet

import shortuuid
shortuuid.set_alphabet("12345")

throws

shortuuid-0.1-py2.6.egg/shortuuid/init.py:40: DeprecationWarning: the sets module is deprecated
from sets import Set as set

python3 -m shortuuid not working

Hello.
I was trying to use cli implementation of your package, but got this error.
python3 -m shortuuid
/.venv/bin/python3: No module named shortuuid.__main__; 'shortuuid' is a package and cannot be directly executed

shortuuid version: 1.0.8
python version: 3.8.6
os: macos

Using pkg_resources makes package load really slow

Heya, this change really hurts package loading times 😬

__version__ = pkg_resources.get_distribution("shortuuid").version

For example, with our CLI this change has meant an increase in load time from ~0.3 seconds to ~0.8 seconds!

pkg_resources is essentially deprecated, in part, for this very reason; replaced by https://docs.python.org/3/library/importlib.metadata.html and the https://github.com/python/importlib_metadata backport

Some new IDs being generated using legacy mode

On shortuuid v1.0.8, I am running into an issue where sometimes generating a new random id results in a legacy mode uuid:

shortuuid.ShortUUID().random(length=22)
>>> 'sPQ3KBZLjzHhETzs3ufGCQ'

shortuuid.decode('sPQ3KBZLjzHhETzs3ufGCQ')
>>> ValueError: int is out of range (need a 128-bit value)

shortuuid.decode('sPQ3KBZLjzHhETzs3ufGCQ', legacy=True)
>>> UUID('7ca96621-cf86-aca5-f7d1-f07d4354140c')

The expected behavior is that any new shortuuid generated could be decoded and re-encoded without having to check for legacy mode:

id = shortuuid.ShortUUID().random(length=22)
id == shortuuid.encode(shortuuid.decode(id))

Namespace type check could be better

ShortUUID determines namespace using the following code:

# If no name is given, generate a random UUID.
if name is None:
    uuid = _uu.uuid4()
elif "http" not in name.lower():
    uuid = _uu.uuid5(_uu.NAMESPACE_DNS, name)
else:
    uuid = _uu.uuid5(_uu.NAMESPACE_URL, name)

However, this should check for http:// or https:// at the beginning of the string, not anywhere in the middle, as it'll currently consider myhttpdomain.com as a URL instead of a domain. The correct if condition is: elif not name.lower().startswith(('http://', 'https://'))

should characters be randomised when padding is needed

This is more of a question than an actual issue at this point, but I was curious if any attempt should be made to randomise the characters taken from self._alphabet if padding is needed for the output?

I've tried to implement this like so:

diff --git a/shortuuid/main.py b/shortuuid/main.py
index 0aa0900..6939a89 100644
--- a/shortuuid/main.py
+++ b/shortuuid/main.py
@@ -4,6 +4,7 @@ import binascii
 import math
 import os
 import uuid as _uu
+import random as _rand


 class ShortUUID(object):
@@ -24,7 +25,10 @@ class ShortUUID(object):
             output += self._alphabet[digit]
         if pad_to_length:
             remainder = max(pad_to_length - len(output), 0)
-            output = output + self._alphabet[0] * remainder
+            output = output + ''.join(
+                map(lambda a: self._alphabet[
+                    _rand.randint(0, len(self._alphabet) - 1)],
+                    range(remainder)))
         return output

     def _string_to_int(self, string):

However unfortunately this consistently fails one of the tests, and another test intermittently errors and or otherwise fails also; the tests in question are test_consistency and test_decoding respectively.

Maybe what I'm suggesting here is completely silly, in which case I'm just curious to understand why that's the case then.

Set the alphabet

If you set the alphabet (for example, I had set '0123456789ABCDEF'), then the length exceeds 22 characters (in my case 32 characters).

Generating invalid ShortUUIDs

I'm calling shortuuid.uuid() in our unit test which run regularly and I'm seeing it generate some invalid UUIDs

Such as 5vHqLc9etTWW3AVrEJvBez.

The library seems to think this is a valid UUID

>>> shortuuid.decode("5vHqLc9etTWW3AVrEJvBez")
UUID('160427e7-f28e-40ee-9f7a-d473721488c8')

But your website does not:
https://shortuuid.com/

I'm also validating this with some Elixir libraries and they are reporting that it's invalid as well.

Any help would be greatly appreciated.

New release has broken existing URLs

I store UUIDs in my database and render to short UUIDs in the UI, especially in URLs. Last week's new releases have broken all my existing URLs because of the MSB issue.

While the legacy=True flag is available, the promise that it will go away in future is not comforting. There is absolutely nothing I can do to withdraw the thousands of existing URLs I have in circulation (as will be the case for anyone who has used ShortUUID in production).

I'd like the option to continue generating legacy short UUIDs forever. The MSB order is irrelevant anyway in a rendered string.

ValueError: int is out of range (need a 128-bit value)

Hello!

Thank you for this package. Need some pieces of advice about decoding. I've found some shortuuids that raises:

...
    return _uu.UUID(int=string_to_int(string, self._alphabet))
  File "/usr/lib/python3.6/uuid.py", line 174, in __init__
    raise ValueError('int is out of range (need a 128-bit value)')
ValueError: int is out of range (need a 128-bit value)

The code:

from shortuuid import decode
decode('pyKuFXRZEDMv4Zng4RgtBz')

Checked on:

  • Python: 3.6
  • shortuuid: 0.5.0 and master

Thank you in advance!

Unfotunate reference uuid in unit test

The uuid chosen in the unit tests ("12345678-1234-5678-1234-567812345678") is not the best choice for reference. I ported your library to Java (great work btw), and for that you need to consider the byte order. The uuid gets split into two 8 byte longs, which in this case are 1234567812345678 and 1234567812345678 - they are identical. At one point in the conversion i accidently switched the LSBs and MSBs, but the unit test succeded anyways.
You might consider chosing another uuid for reference.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.