Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tanbro/b64uuid
A small Python library and command-line tool to encode/decode UUID to/from a 22 characters shorter URL safe base64 string.
https://github.com/tanbro/b64uuid
base64 pypi python python-3 python-library python3 shortid urlsafe urlsafe-base64 uuid uuid-string
Last synced: 1 day ago
JSON representation
A small Python library and command-line tool to encode/decode UUID to/from a 22 characters shorter URL safe base64 string.
- Host: GitHub
- URL: https://github.com/tanbro/b64uuid
- Owner: tanbro
- License: agpl-3.0
- Created: 2020-08-06T02:09:29.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-09-23T03:27:22.000Z (over 3 years ago)
- Last Synced: 2025-01-18T11:16:57.271Z (8 days ago)
- Topics: base64, pypi, python, python-3, python-library, python3, shortid, urlsafe, urlsafe-base64, uuid, uuid-string
- Language: Python
- Homepage:
- Size: 55.7 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# b64uuid
---
[![pytest](https://github.com/tanbro/b64uuid/workflows/pytest/badge.svg)](https://github.com/tanbro/b64uuid/actions?query=workflow%3Apytest)
[![PyPI](https://img.shields.io/pypi/v/b64uuid.svg)](https://pypi.org/project/b64uuid)
[![Documentation Status](https://readthedocs.org/projects/b64uuid/badge/?version=latest)](https://b64uuid.readthedocs.io/en/latest/?badge=latest)---
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](https://pypi.org/):
```bash
pip install b64uuid
```- Installing from a local src tree:
```bash
pip install .
```or
```bash
python setup.py install
```Check for more details.
## Command Line Usages
- Make a random short ID
```bash
$ b64uuid
bxntPh4PSA6-OMDfBXMLhQ
```- Short ID from UUID
```sh
$ b64uuid -u 2863a16d-b6ae-45a2-9d74-98d20377d56a
KGOhbbauRaKddJjSA3fVag
```- Short ID to UUID
```sh
$ b64uuid -s KGOhbbauRaKddJjSA3fVag
2863a16d-b6ae-45a2-9d74-98d20377d56a
```## Library Usages
- Make a random short ID
```python
>>> from b64uuid import B64UUID
>>>
>>> B64UUID().string
'Ft018l4aTwalxqDHMQoqTQ'
```- Short ID from UUID
```python
>>> 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
```python
>>> 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'
```