Adding documentation comments for doxygen (#1)
This commit is contained in:
@@ -1,16 +1,58 @@
|
||||
# This Python file uses the following encoding: utf-8
|
||||
"""! @brief Defines the encryption class."""
|
||||
##
|
||||
# @file Vermasseln.py
|
||||
#
|
||||
# @brief Defines the Vermasseln class.
|
||||
#
|
||||
# @section description_vermasseln Description
|
||||
# Defines the base class for the program encryption mechansim.
|
||||
# - Vermasseln (base class)
|
||||
#
|
||||
# @section libraries_configloader Libraries/Modules
|
||||
# - <a href="https://docs.python.org/3/library/platform.html">platform</a> Python standard library
|
||||
# - Access to underlying platform’s identifying data.
|
||||
# - <a href="https://docs.python.org/3/library/base64.html">base64</a> Python standard library
|
||||
# - Provides functions for encoding binary data to printable ASCII characters and decoding such encodings back to binary data.
|
||||
# - <a href="https://docs.python.org/3/library/random.html">random</a> Python module
|
||||
# - Implements pseudo-random number generators for various distributions.
|
||||
# - <a href="https://docs.python.org/3/library/string.html">string</a> Python standard library
|
||||
# - Common string operations.
|
||||
# - <a href="https://pycryptodome.readthedocs.io/en/latest/src/api.html">Crypto</a> Python package
|
||||
# - Provides cryptographic functionalities.
|
||||
#
|
||||
# @section notes_vermasseln Notes
|
||||
# - None.
|
||||
#
|
||||
# @section todo_vermasseln TODO
|
||||
# - None.
|
||||
#
|
||||
# @section author_vermasseln Author(s)
|
||||
# - Created by Linuxero on 03/14/2025.
|
||||
# - Modified by Linuxero on 03/14/2025.
|
||||
#
|
||||
# Copyright (c) 2025 Schnaxero. All rights reserved.
|
||||
|
||||
from Crypto.Cipher import AES
|
||||
from base64 import b64encode, b64decode
|
||||
import platform
|
||||
from Crypto.Hash import SHA256, SHA3_512
|
||||
from Crypto.Protocol.KDF import PBKDF2
|
||||
from Crypto.Random import get_random_bytes
|
||||
# from Crypto.Protocol.KDF import PBKDF2
|
||||
# from Crypto.Random import get_random_bytes
|
||||
import random
|
||||
import string
|
||||
|
||||
|
||||
class Vermasseln:
|
||||
"""! The Vermasseln class.
|
||||
Defines the class utilized by different parts of the program.
|
||||
Handles the encryption/decryption of the whole program.
|
||||
"""
|
||||
def oscarVermasseln(self, data, local= True):
|
||||
"""! Encrypts data.
|
||||
@param data The data to encrypt.
|
||||
@param local Is the encryption local to the host or not?
|
||||
@return encrypted data.
|
||||
"""
|
||||
b_data = data.encode("utf-8")
|
||||
cipher = self.__vermasslungsKobold(local)
|
||||
|
||||
@@ -21,6 +63,11 @@ class Vermasseln:
|
||||
return storable_data
|
||||
|
||||
def entschluesseln(self, data, local = True):
|
||||
"""! Decrypts data.
|
||||
@param data The data to decrypt.
|
||||
@param local Is the encryption local to the host or not?
|
||||
@return decrypted data on success, None on failure.
|
||||
"""
|
||||
try:
|
||||
data_list = data.split(".")
|
||||
encoded_data = [b64decode(x) for x in data_list]
|
||||
@@ -38,6 +85,10 @@ class Vermasseln:
|
||||
return decrypted_data
|
||||
|
||||
def __vermasslungsKobold(self, local = True):
|
||||
"""! Prepares the encryption key.
|
||||
@param local Is the encryption local to the host or not?
|
||||
@return encryption key.
|
||||
"""
|
||||
key = platform.processor().encode("utf-8") if local else b"(==daniishtverhaftetwegensexy#)"
|
||||
key = key[0:31]
|
||||
hash_key = SHA256.new(key)
|
||||
@@ -48,6 +99,11 @@ class Vermasseln:
|
||||
|
||||
@classmethod
|
||||
def userPasswordHash(self, password, salt = None):
|
||||
"""! Hashes data.
|
||||
@param password The data to hash.
|
||||
@param salt The salt to use if available.
|
||||
@return hashed data.
|
||||
"""
|
||||
if not salt:
|
||||
salt = "".join(random.choice(string.ascii_letters + string.digits) for i in range (32))
|
||||
hash_pw = (salt + password).encode("utf-8")
|
||||
|
||||
Reference in New Issue
Block a user