Skip to content

Instantly share code, notes, and snippets.

@Conaclos
Last active March 28, 2022 13:20
Show Gist options
  • Select an option

  • Save Conaclos/865c86faeeeaab988ac0f753f6e07dad to your computer and use it in GitHub Desktop.

Select an option

Save Conaclos/865c86faeeeaab988ac0f753f6e07dad to your computer and use it in GitHub Desktop.

Revisions

  1. Conaclos revised this gist Mar 28, 2022. 1 changed file with 20 additions and 20 deletions.
    40 changes: 20 additions & 20 deletions sqlite-base64-gid96.md
    Original file line number Diff line number Diff line change
    @@ -2,24 +2,24 @@ The following SQL statement enables to generate a base64 uuid encoded on 96bits

    ```sql
    SELECT (substr(chars, (first & 63)+1, 1) ||
    substr(chars, ((first >> 6) & 63)+1, 1) ||
    substr(chars, ((first >> 12) & 63)+1, 1) ||
    substr(chars, ((first >> 18) & 63)+1, 1) ||
    substr(chars, ((first >> 24) & 63)+1, 1) ||
    substr(chars, ((first >> 30) & 63)+1, 1) ||
    substr(chars, ((first >> 36) & 63)+1, 1) ||
    substr(chars, ((first >> 42) & 63)+1, 1) ||
    substr(chars, (second & 63)+1, 1) ||
    substr(chars, ((second >> 6) & 63)+1, 1) ||
    substr(chars, ((second >> 12) & 63)+1, 1) ||
    substr(chars, ((second >> 18) & 63)+1, 1) ||
    substr(chars, ((second >> 24) & 63)+1, 1) ||
    substr(chars, ((second >> 30) & 63)+1, 1) ||
    substr(chars, ((second >> 36) & 63)+1, 1) ||
    substr(chars, ((second >> 42) & 63)+1, 1)) as uuid
    FROM (
    SELECT 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' as chars,
    random() as first,
    random() as second
    );
    substr(chars, ((first >> 6) & 63)+1, 1) ||
    substr(chars, ((first >> 12) & 63)+1, 1) ||
    substr(chars, ((first >> 18) & 63)+1, 1) ||
    substr(chars, ((first >> 24) & 63)+1, 1) ||
    substr(chars, ((first >> 30) & 63)+1, 1) ||
    substr(chars, ((first >> 36) & 63)+1, 1) ||
    substr(chars, ((first >> 42) & 63)+1, 1) ||
    substr(chars, (second & 63)+1, 1) ||
    substr(chars, ((second >> 6) & 63)+1, 1) ||
    substr(chars, ((second >> 12) & 63)+1, 1) ||
    substr(chars, ((second >> 18) & 63)+1, 1) ||
    substr(chars, ((second >> 24) & 63)+1, 1) ||
    substr(chars, ((second >> 30) & 63)+1, 1) ||
    substr(chars, ((second >> 36) & 63)+1, 1) ||
    substr(chars, ((second >> 42) & 63)+1, 1)) as uuid
    FROM (
    SELECT 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' as chars,
    random() as first,
    random() as second
    );
    ```
  2. Conaclos revised this gist Mar 28, 2022. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions sqlite-base64-gid96.md
    Original file line number Diff line number Diff line change
    @@ -19,7 +19,7 @@ SELECT (substr(chars, (first & 63)+1, 1) ||
    substr(chars, ((second >> 42) & 63)+1, 1)) as uuid
    FROM (
    SELECT 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' as chars,
    random() as first,
    random() as second
    random() as first,
    random() as second
    );
    ```
  3. Conaclos created this gist Mar 28, 2022.
    25 changes: 25 additions & 0 deletions sqlite-base64-gid96.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,25 @@
    The following SQL statement enables to generate a base64 uuid encoded on 96bits (12 octects).

    ```sql
    SELECT (substr(chars, (first & 63)+1, 1) ||
    substr(chars, ((first >> 6) & 63)+1, 1) ||
    substr(chars, ((first >> 12) & 63)+1, 1) ||
    substr(chars, ((first >> 18) & 63)+1, 1) ||
    substr(chars, ((first >> 24) & 63)+1, 1) ||
    substr(chars, ((first >> 30) & 63)+1, 1) ||
    substr(chars, ((first >> 36) & 63)+1, 1) ||
    substr(chars, ((first >> 42) & 63)+1, 1) ||
    substr(chars, (second & 63)+1, 1) ||
    substr(chars, ((second >> 6) & 63)+1, 1) ||
    substr(chars, ((second >> 12) & 63)+1, 1) ||
    substr(chars, ((second >> 18) & 63)+1, 1) ||
    substr(chars, ((second >> 24) & 63)+1, 1) ||
    substr(chars, ((second >> 30) & 63)+1, 1) ||
    substr(chars, ((second >> 36) & 63)+1, 1) ||
    substr(chars, ((second >> 42) & 63)+1, 1)) as uuid
    FROM (
    SELECT 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' as chars,
    random() as first,
    random() as second
    );
    ```