Generates a base 64 random number of an arbitrary length.
base64_random uses Python's secrets module to generate the random numbers, so you should be able to generate high
quality random numbers when using this library. That said, I cannot recommend that this library be used in contexts
where high-quality random numbers are used to secure sensitive information. Please use a suitable cryptography library
for contexts where you need to protect information.
Please also note, that as of the time of writing, this library provides NO SUPPORT for Base64 encoding or decoding. Additionally, this library generates numbers in base 64, it has no relation to the Base64 encoding format.
There are two main ways to use this package, command line invocation and importing the module.
Command line usage is quite easy, simply pass the module the length of number you wish to generate:
python -m base64_random 10Or, by invoking the shell script:
b64r 10You can also import this module in your code to use it:
from base64_random import gen_random_base64
base64_number = gen_random_base64(10)
print(base64_number)base64_random is available on pip!
pip install base64-randomYou can also install base64-random directly from git, but please refer to the
official documentation for the details
of how to do that.
If you wish to build base64-random directly from the source code, you can do that by following these steps:
- Clone the repo from GitHub.
- Install dependencies. I highly recommend that you use
pipenvfor this purpose. The only dependencies are those required to build the library itself.- If you do use pipenv to install dependencies, make sure to activate the shell environment by running
pipenv shell.
- If you do use pipenv to install dependencies, make sure to activate the shell environment by running
- Once dependencies are installed, simply run the python build module:
python -m build- If you have followed all the instructions correctly, then you should now have a
*.whlfile and a*.tar.gzfile in thedistdirectory. - Once the wheel file is generated, you can install it by running
pipenv install dist/base64_random-<VERSION>.whl. if you prefer to install withpip, you can do so by running the very similar command:pip install dist/base64_random-<VERSION>.whl.
You're done! You should now be able to import the library.