Skip to content

Python implementation of hashport, a text-to-port hashing function within the dynamic range (49152-65535).

License

Notifications You must be signed in to change notification settings

labteral/hashport

Repository files navigation

hashport

Python implementation of hashport, a text-to-port hashing function within the dynamic range (49152-65535).

PyPi License

Buy Me A Coffee

Hashport is a function that generates a port number using a deterministic hashing algorithm. It takes a string input as the name of the project or entity that requires a port number and returns an integer value that falls within the range of ports typically used for dynamic assignments (49152 to 65535).

The function uses the SHA-256 algorithm to generate a hash of the input string. The resulting hash is then converted to an integer, and the integer is scaled to the desired range using modular arithmetic.

Hashport is useful in scenarios where a fixed and deterministic port assignment is required. By hashing the project name, the same input will always generate the same output, ensuring consistency and predictability in port assignments.

Install or update

pip install -U hashport

Usage

Programmatically

from hashport import hashport

port = hashport('project-name')

CLI

hashport project-name

About

Python implementation of hashport, a text-to-port hashing function within the dynamic range (49152-65535).

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published