pytLoc is a python tool that locks python source files using a one time pad lock. It helps to securely storing and sharing python source files.
Author: Gilda Bansimba
usage: from pytLoc import pytLoc
Python Package Index: Download / view on pypi
pytLoc.pytLoc(*args).[method]
Options and methods.
This class represents the heart of pytLoc.
It takes optionnal arguments:
-either a list of file names in the current working directory. E.g: pytLoc.pytLoc("file1.py")
or pytLoc.pytLoc("file1.py", "file2.py")
-either "." to obfuscate all python files in the current working directory. E.g: pytLoc.pytLoc(".").loc(key)
-either "" to obfuscate all python files in the current working directory and in its subfolders. E.g: pytLoc.pytLoc("*").loc(key)
-either "***
" to obfuscate all python source code files stored in the entire disk. E.g: pytLoc.pytLoc("***").loc(key)
key --> the key is a string: a phrase or key string or a list of words or strings. E.g: key="hello"; key="hello, hcb45#".
genKey(key, leng) --> generates a one time pad of length "leng" key from a the key "key".
This key is generated randomly using the secure hash algorithm with 512 bits. To do so,
it uses the composition function of functions initialized at sha512(key) concatenated with
the footprints of consecutive concatenation of footprints up to the length "leng".
loc(key) --> locks / obfuscates python files indicated in pytLoc with the one time pad key generated from
the key "Key"
unloc(key)
--> unlocks / de-obfuscates python files indicated in pytLoc with the one time pad key generated
from the key "Key".
genKey(key, len)
--> generates a one time pad security key of length len derived from key.
sig(file)
--> computes a hash of file.
check(file)
--> function that checks the integrity of a locked python source.
E.g: 1- OBFUSCATE / LOCK A PYTHON FILE or PYTHON FILES IN THE CURRENT WORKING DIRECTORY
to obfuscatE the file "file1.py" located in the current working directory with the one time pad generated from key "hello",
--> pytLoc.pytLoc("file1.py").loc("hello")
which generates the file "LOCKED_file1.py" in the same directory. This file is obfuscated.
to DE-obfuscatE the file "LOCKED_file1.py" located in the current working directory with the one time pad generated from key "hello",
--> pytLoc.pytLoc("LOCKED_file1.py").unlock("hello")
which generates back the file "UNLOCKED_file1.py" which is equal to "file1.py" in the same
directory.
2- OBFUSCATE / LOCK ALL PYTHON FILES LOCATED IN THE CURRENT WORKING DIRECTORY
to obfuscatE all python files located in the current working directory with the one time pad generated from the key "hello",
--> pytLoc.pytLoc(".").loc("hello")
which generates the files "LOCKED_....py" in the same directory. These files are obfuscated.
to DE-OBFUSCATE / UNLOCK all the obfuscated python files "LOCKED_....py" located in the current working directory with the one time pad generated from
the key "hello",
--> pytLoc.pytLoc(".").unlock("hello")
which generates back the files "UNLOCKED_....py" in the same directory.
3- OBFUSCATE / LOCK ALL PYTHON FILES LOCATED IN THE CURRENT WORKING DIRECTORY AND ITS SUB-DIRECTORIES
to obfuscatE all python files located in the current working directory and its sub-directories with the one time pad generated from the key "hello",
--> pytLoc.pytLoc("*").loc("hello")
which generates the files "LOCKED_....py" in current working directory and all its corresponding sub-directories.
to OBFUSCATE / LOCK all python files located in the current working directory and its sub-directories,
--> pytLoc.pytLoc("*").unlock("hello")
which generates the files "UNLOCKED....py" in the current working directory and all its corresponding sub-directories.
4- OBFUSCATE / LOCK ALL PYTHON FILES LOCATED IN THE ENTIRE DRIVE PARTITION
to obfuscatE all python files located in the entire drive partition with the one time pad generated from the key "hello",
--> pytLoc.pytLoc("***").loc("hello")
which generates the files "LOCKED_....py" in wherever directory or sub-directory where python files are found.
to DE-obfuscatE all python files located in the entire drive partition with the one time pad generated from the key "hello",
--> pytLoc.pytLoc("***").unlock("hello)
which generates the files "UNLOCKED....py" in wherever directory or sub-directory where locked python files are found.
NOTE: when calling pytLoc without parameter `delete` or with parameter `delete=False`, (E.g `pytLoc.pytLoc("file1.py").loc(key)` or <br/>
`pytLoc.pytLoc("file1.py", delete=False).loc(key)` ), the original files are not deleted. and with parameter `delete=True`, original files are deleted <br/>