Giter VIP home page Giter VIP logo

b64uuid's Introduction

b64uuid


pytest PyPI Documentation Status


A small Python library and command-line tool to encode/decode UUID to/from a 22 characters shorter URL safe base64 string.

We can use it to make UUID string a little shorter.

Installation

  • Installing from PyPI:

    pip install b64uuid
  • Installing from a local src tree:

    pip install .

    or

    python setup.py install

Check https://packaging.python.org/tutorials/installing-packages for more details.

Command Line Usages

  • Make a random short ID

    $ b64uuid
    bxntPh4PSA6-OMDfBXMLhQ
  • Short ID from UUID

    $ b64uuid -u 2863a16d-b6ae-45a2-9d74-98d20377d56a
    KGOhbbauRaKddJjSA3fVag
  • Short ID to UUID

    $ b64uuid -s KGOhbbauRaKddJjSA3fVag
    2863a16d-b6ae-45a2-9d74-98d20377d56a

Library Usages

  • Make a random short ID

    >>> from b64uuid import B64UUID
    >>>
    >>> B64UUID().string
    'Ft018l4aTwalxqDHMQoqTQ'
  • Short ID from UUID

    >>> from uuid import uuid1
    >>> from b64uuid import B64UUID
    >>>
    >>> uid = uuid1()
    >>> str(uid)
    'cb6e319c-d793-11ea-9619-1cb72cde3f7f'
    >>> bid = B64UUID(uid)
    >>> str(bid)
    'y24xnNeTEeqWGRy3LN4_fw'
  • Short ID to UUID

    >>> from uuid import uuid1
    >>> from b64uuid import B64UUID
    >>>
    >>> uid = uuid1()
    >>> uid.hex
    '95327416d79411ea96191cb72cde3f7f'
    >>> short_id = B64UUID(uid).string
    >>> short_id
    'lTJ0FteUEeqWGRy3LN4_fw'
    >>> B64UUID(short_id).uuid.hex
    '95327416d79411ea96191cb72cde3f7f'

b64uuid's People

Contributors

tanbro avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

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.