CodeSafe Package Documentation
Package documentation for CodeSafe. An open-source Python library for code encryption, decryption, and safe evaluation using Python's built-in AST module, with complete control over execution.
Changelog
0.0.3 (Latest): Added a parameter for
allow_attributesand setimmediate_terminationto beTrueby default for safer function calling.0.0.2: Removed unnecessary print statements and added error handling for most functions. Related to https://github.com/Infinitode/CodeSafe/pull/1. Thanks to @0XC7R for contributing!
0.0.1: Initial release.
Installation
You can install CodeSafe using PyPi, please make sure that you are using Python 3.6 or later before installing CodeSafe:
pip install codesafeCodeSafe is an experimental library, and we're still running some tests on it. Please let us know if you encounter any issues or have an edge use case.
Example Usage
Safe Eval
from codesafe import safe_eval
if __name__ == '__main__':
# Run a normal, safe expression
expression = "1 + 1"
disallowed_expression = "os.getcwd()"
result1 = safe_eval(expression, timeout=10, immediate_termination=True)
result2 = safe_eval(disallowed_expression, timeout=10, immediate_termination=True)Encrypt & Run Code
Last updated
Was this helpful?