Skip to main content

An Integer ID Disguiser to make your values look more professional.

Project description

Disid

An Integer ID Disguiser to make your values look more professional.

Transform plain incrementing ids:

https://example.com/blogpost/1
https://example.com/blogpost/2
https://example.com/blogpost/3
https://example.com/blogpost/4

Into random looking values befitting of a popular website:

https://example.com/blogpost/WxYRW
https://example.com/blogpost/2zfow
https://example.com/blogpost/SyyUZ
https://example.com/blogpost/EIrPp

The process is reversable and does not need access to a database. A optional static key file can be distributed among all of the processes that need to convert between a Disid id and a numerical value.

Example

from typing import List
import os
import keytools
import disid

def load_key(file: str) -> List[str]:
    if os.path.exists(file):
        with open(file, 'rb') as f:
            key = f.read()
    else:
        with open(file, 'wb') as f:
            key = keytools.generate_key(5)
            f.write(key)

    return keytools.convert_key_to_character_lists(key)

def main():
    character_list = load_key("my_keyfile.key")
    print(disid.uint_to_id_v3(1, character_list))
    print(disid.uint_to_id_v3(2, character_list))
    print(disid.uint_to_id_v3(3, character_list))
    print(disid.uint_to_id_v3(4, character_list))

Security

This should not be considered cryptographically secure. Do not use Disid to expose values to a user that should otherwise not be exposed. Only use Disid as a cosmetic layer on top of your already public values.

Project details


Release history Release notifications | RSS feed

This version

0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

disid-0.1.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

disid-0.1-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file disid-0.1.tar.gz.

File metadata

  • Download URL: disid-0.1.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for disid-0.1.tar.gz
Algorithm Hash digest
SHA256 53c49035b187f101074955026a2e8e0aef8aae7885f012eb3788daf1dbfec6fd
MD5 b01169427ac90ec120cc0dbb5bcf1942
BLAKE2b-256 1ae24c029e9c26e15dcec98aa638a781ac97e2d3af75d66994aa249bf1f0c4b4

See more details on using hashes here.

File details

Details for the file disid-0.1-py3-none-any.whl.

File metadata

  • Download URL: disid-0.1-py3-none-any.whl
  • Upload date:
  • Size: 6.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for disid-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6fb00a1139b464f4286b3c6813429a6f284c3510fbcae87db554ccb08d6a43e2
MD5 b30b481a93e16dc9372695fdcb177691
BLAKE2b-256 4a41cc01e28faf6fd6a8ed9994b448c47168ea9e0bf009d0bb1d481d9425f293

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page