https://github.com/devknown/alpha-id-py
Python library for generating short alphanumeric strings from integers
https://github.com/devknown/alpha-id-py
Last synced: 2 months ago
JSON representation
Python library for generating short alphanumeric strings from integers
- Host: GitHub
- URL: https://github.com/devknown/alpha-id-py
- Owner: devknown
- License: mit
- Created: 2023-06-20T04:46:55.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-05-09T21:55:27.000Z (about 1 year ago)
- Last Synced: 2025-03-01T04:36:34.850Z (3 months ago)
- Language: Python
- Size: 14.6 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
AlphaID - Convert any integer to a short alphanumeric version
# alpha-id-py
`alpha-id-py` is a Python library that allows you to generate short alphanumeric strings from integers. It can be useful for creating compact, unique, and obfuscated identifiers.
## AlphaID Library Versions
These versions should all function harmoniously, allowing for encoding in one language and decoding in another.
- [PHP Version](https://github.com/devknown/alpha-id)
- [JavaScript Version](https://github.com/devknown/alpha-id-js)
- [Python Version](https://github.com/devknown/alpha-id-py)## Installation
You can install `alpha-id-py` using pip:
```bash
pip install alpha-id-py
```## Getting Started
Simple usage looks like this:
```python
from alpha_id.alpha_id import AlphaIDalpha_id = AlphaID()
encoded_string = alpha_id.convert(258456357951)
print(encoded_string)
# Output: '4y7exoH'original_number = alpha_id.recover('4y7exoH')
print(original_number)
# Output: 258456357951
```## Configuring a Global Key
You can set a global key that will be used for encoding and decoding if no specific key is provided. This can be done using the `config` method:
```python
from alpha_id.alpha_id import AlphaIDalpha_id = AlphaID()
alpha_id.config('my_key')encoded_string = alpha_id.convert(258456357951)
print(encoded_string)
# Output: '4ymMZq9'original_number = alpha_id.recover('4ymMZq9')
print(original_number)
# Output: 258456357951
```## License
`alpha-id-py` is open-source software licensed under the [MIT license](https://opensource.org/licenses/MIT).