Generating 8-character only UUIDs

It is not possible since a UUID is a 16-byte number per definition. But of course, you can generate 8-character long unique strings (see the other answers). Also be careful with generating longer UUIDs and substring-ing them, since some parts of the ID may contain fixed bytes (e.g. this is the case with MAC, DCE … Read more

Using a UUID as a primary key in Django models (generic relations impact)

As seen in the documentation, from Django 1.8 there is a built in UUID field. The performance differences when using a UUID vs integer are negligible. import uuid from django.db import models class MyUUIDModel(models.Model): id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) You can also check this answer for more information.

How to Create Deterministic Guids

As mentioned by @bacar, RFC 4122 ยง4.3 defines a way to create a name-based UUID. The advantage of doing this (over just using a MD5 hash) is that these are guaranteed not to collide with non-named-based UUIDs, and have a very (very) small possibility of collision with other name-based UUIDs. There’s no native support in … Read more

How to generate unique id in Dart

1. There is a UUID pub package: http://pub.dartlang.org/packages/uuid example usage: import ‘package:uuid/uuid.dart’; // Create uuid object var uuid = Uuid(); // Generate a v1 (time-based) id uuid.v1(); // -> ‘6c84fb90-12c4-11e1-840d-7b25c5ee775a’ // Generate a v4 (random) id uuid.v4(); // -> ‘110ec58a-a0f2-4ac4-8393-c866d813b8d1’ // Generate a v5 (namespace-name-sha1-based) id uuid.v5(uuid.NAMESPACE_URL, ‘www.google.com’); // -> ‘c74a196f-f19d-5ea9-bffd-a2742432fc9c’ 2. This src has … Read more

How to determine if a string is a valid v4 UUID? [duplicate]

I found this question while I was looking for a Python answer. To help people in the same situation, I’ve added the Python solution. You can use the uuid module: #!/usr/bin/env python from uuid import UUID def is_valid_uuid(uuid_to_test, version=4): “”” Check if uuid_to_test is a valid UUID. Parameters ———- uuid_to_test : str version : {1, … Read more