A python utility library is written by huykingsofm
Project description
hks_pylib
A Python 3 utility library of huykingsofm. It has some modules, including:
logger
: A module is used to print notifications to the console screen or write logs to file. It is special because you can disable the print/write statement by modifying a few parameters without commenting or deleting them manually.cryptography
: A wrapper crypto module bases on and is followed by the implementation style of cryptography. It is easier to use than the original one and fits many procedures in our projects.done
: A module defines a class (Done
) for returning complex values more conveniently.http
: A module is used to parse or generate raw HTTP packets.math
: A module implements some no-builtin mathematic operations.hksenum
: A wrapper module ofEnum
is more convenient than the original.files
: A file processing module.
How to build
Our library is only supported by Python>=3.7.1. Now we test it only on Python 3.7.1. If you meet any problems, even if with other versions, you could create an issue to notify us. We will solve them as quickly as possible.
Create Virtual Environment (optional but IMPORTANT)
If you had your virtual environment, you can ignore this step.
You ought to create a virtual environment to avoid conflicting with other applications on your machine when installing our module. The virtual environment must be installed with Python 3.
I highly recommend you to use Anaconda because of its utilities. The command of creating a virtual environment in Anaconda is:
$ conda create -n your_venv_name python=3.7.1
$ conda activate your_venv_name
(your_venv_name) $ _
Or use Python venv
:
$ python -m venv path/to/your/venv
$ path/to/your/venv/Scripts/activate.bat
(your_venv_name) $ _
Method 1: Install the stablest version (PyPI)
(your_venv_name) $ pip install hks_pylib
Method 2: Install the newest version (Github)
(your_venv_name) $ git clone https://github.com/huykingsofm/hks_pylib.git
(your_venv_name) $ cd hks_pylib
(your_venv_name) hks_pylib $ pip install -e .
How to use
Just use import
statement and enjoy it. We will write documentation and tutorials as soon as possible so that you can understand our library easier.
# A Done object can be used to substitute
# complex return values
from hks_pylib.done import Done
# Example: return Done(True, reason="OK")
# A class is used to print/write
# logs to console/file
from hks_pylib.logger import StandardLogger
# A class is used to generate StandardLogger objects.
# You should use this class instead of
# using StandardLogger directly
from hks_pylib.logger import StandardLoggerGenerator
# You may use our console_output instead of print builtin function
# in a multithread program
from hks_pylib.logger import acprint
acprint("Something")
# Some common ciphers
from hks_pylib.cipher import NoCipher, AES_CBC, HybridCipher
# You can parse or generate raw HTTP packets with these class
from hks_pylib.http import HTTPParser, HTTPPacket
# You can encrypt or decrypt your data with our cryptography module
from hks_pylib.cryptography.ciphers.symmetrics import AES_CTR, AES_CBC
from hks_pylib.cryptography.ciphers.asymmetrics import RSAKey, RSACipher
# or hash functions
from hks_pylib.cryptography.hashes import SHA1, SHA256
# or Diffie Hellman
from hks_pylib.cryptography.protocols import DiffieHellmanExchange
Change log
Version 0.0.7 -- 0.0.8
- Fix the error of
InvisibleLogger
. - Fix
reset()
inAES_CTR
andAES_CBC
. - Fix
save...()
andload...()
inRSAKey
. - Add the
acprint(.)
for avoid conflicting print. - Add
@as_object
decorator. - Add
MD5
tohashes
. - Add
KeyGenerator
tociphers
.
Version 0.0.6
- Change .gitignore to template of Python.
- Change the
http
style. - Change the
logger
toHKSEnum
style. - Add
InvisibleLoggerGenerator
,InvisibleLogger
for more convenient. - Add some utility methods to
HKSEnum
andDone
. - Change many error types and replace some errors to
hkserror
.
Version 0.0.5
- Change allmost all generic exceptions to highly identified exceptions (in modules of
hks_pylib.errors
). - Add the
Output
class tohks_pylib.logger.config
. Now logger can easily avoid conflicting in printing. - Add a wrapper module
hks_pylib.hksenum
of builtin python classEnum
. Change many constants toHKSEnum
type. - Divide module
hks_pylib.cryptography.ciphers
into multiple submodules and move them to foldercryptography/ciphers/
. - Divide module
hks_pylib.logger
into multiple submodules and move them to folderlogger/
. - Remove
requirements.txt
. - Add
Bitwise
operator tomath
. - Add
batchcrypt
module tohks_pylib.cryptography
. - Add an example of
batchcrypt
in folderexamples/
.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file hks_pylib-0.0.8.tar.gz
.
File metadata
- Download URL: hks_pylib-0.0.8.tar.gz
- Upload date:
- Size: 23.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bbaeb990a312dc4a536ea56bb7cd5f9a82cbadcf0fc0c8f5008773a0121ad275 |
|
MD5 | faa020fd5727c420e52872a66c11c7fa |
|
BLAKE2b-256 | 8075f2c1895386291e2a5fe3527091129ad1fa6473040f1d58547821216a6841 |
File details
Details for the file hks_pylib-0.0.8-py3-none-any.whl
.
File metadata
- Download URL: hks_pylib-0.0.8-py3-none-any.whl
- Upload date:
- Size: 34.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 514899dad27910af509462509feb7e734aa41b86a5f71ff3a31a62c9662411a4 |
|
MD5 | 4c0d6402083755cd276aa0ad5e8c51fd |
|
BLAKE2b-256 | 56ffdc665363025aca0b7721a51988efe87cb467da8cf2bf3ec0ec4f92e900c8 |