absfuyu.tools package
Absfuyu: Tools
Some useful tools
Version: 5.1.0 Date updated: 10/03/2025 (dd/mm/yyyy)
- class absfuyu.tools.Checksum(path: str | Path, hash_mode: ChecksumMode | Literal['md5', 'sha1', 'sha256', 'sha512'] = ChecksumMode.SHA256, save_result_to_file: bool = False)[source]
Bases:
BaseClass
Checksum engine
- Parameters:
path (str | Path) – Path to file/directory to perform checksum
hash_mode (ChecksumMode | Literal["md5", "sha1", "sha256", "sha512"], optional) – Hash mode, by default
"sha256"
save_result_to_file (bool, optional) – Save checksum result(s) to file, by default
False
Added in version 4.1.0
Changed in version 4.1.1: Checksum for entire folder is possible
- class absfuyu.tools.Base64EncodeDecode[source]
Bases:
BaseClass
Encode and decode base64
Added in version 3.0.0
- static encode_image(img_path: Path | str, data_tag: bool = False) str [source]
Encode image file into base64 string
- Parameters:
img_path (Path | str) – Path to image
data_tag (bool, optional) – Add data tag before base64 string, by default
False
- Returns:
Encoded image
- Return type:
str
Added in version 4.1.0
- class absfuyu.tools.Text2Chemistry[source]
Bases:
BaseClass
- property unvailable_characters: set[str]
Characters that can not be converted (unvailable chemistry symbol)
- Returns:
Set of unvailable characters
- Return type:
set[str]
- convert(text: str) list[list[ChemistryElement]] | list [source]
Convert text to chemistry symbol
- Parameters:
text (str) – Desired text
- Returns:
Converted text (empty list when failed to convert)
- Return type:
list[list[ChemistryElement]] | list
- Raises:
ValueError – When text contains digit, whitespaces, …
- class absfuyu.tools.Charset[source]
Bases:
object
Character set data class
- DEFAULT = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
- ALPHABET = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
- FULL = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~'
- UPPERCASE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
- LOWERCASE = 'abcdefghijklmnopqrstuvwxyz'
- DIGIT = '0123456789'
- SPECIAL = '!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~'
- ALL = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~ \t\n\r\x0b\x0c'
- PRODUCT_KEY = 'BCDFGHJKMNPQRTVWXY2346789'
- class absfuyu.tools.Generator[source]
Bases:
BaseClass
Generator that generate stuffs
- static generate_string(charset: str = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789', size: int = 8, times: int = 1, unique: bool = False, string_type_if_1: bool = False)[source]
Generate a list of random string from character set (Random string generator)
- Parameters:
charset (str) –
Use custom character set or character sets already defined in
Charset
Charset.DEFAULT
: character in [a-zA-Z0-9] (default)Charset.ALPHABET
: character in [a-zA-Z]Charset.FULL
: character in [a-zA-Z0-9] + special charactersCharset.UPPERCASE
: character in [A-Z]Charset.LOWERCASE
: character in [a-z]Charset.DIGIT
: character in [0-9]Charset.SPECIAL
: character in [!@#$%^&*()_+=-]Charset.ALL
: character in every printable character
size (int) – Length of each string in list (Default:
8
)times (int) – How many random string generated (Default:
1
)unique (bool) – Each generated text is unique (Default:
False
)string_type_if_1 (bool) – Return a
str
type result iftimes == 1
(Default:False
)
- Returns:
list – List of random string generated
str – When
string_type_if_1
isTrue
None – When invalid option
Example:
>>> Generator.generate_string(times=3) ['67Xfh1fv', 'iChcGz9P', 'u82fNzlm']
- classmethod generate_key(charset: str = 'BCDFGHJKMNPQRTVWXY2346789', letter_per_block: int = 5, number_of_block: int = 5, sep: str = '-') str [source]
Generate custom key
- Parameters:
charset (str) – Character set (Default:
Charset.PRODUCT_KEY
)letter_per_block (int) – Number of letter per key block (Default:
5
)number_of_block (int) – Number of key block (Default:
5
)sep (str) – Key block separator (Default:
-
)
- Returns:
Generated key
- Return type:
str
Example:
>>> Generator.generate_key(letter_per_block=10, number_of_block=2) 'VKKPJVYD2H-M7R687QCV2'
- static generate_check_digit(number: int) int [source]
Check digit generator
“A check digit is a form of redundancy check used for error detection on identification numbers, such as bank account numbers, which are used in an application where they will at least sometimes be input manually. It is analogous to a binary parity bit used to check for errors in computer-generated data. It consists of one or more digits (or letters) computed by an algorithm from the other digits (or letters) in the sequence input. With a check digit, one can detect simple errors in the input of a series of characters (usually digits) such as a single mistyped digit or some permutations of two successive digits.” (Wikipedia)
This function use Luhn’s algorithm to calculate
- Parameters:
number (int) – Number to calculate check digit
- Returns:
Check digit
- Return type:
int
Example:
>>> Generator.generate_check_digit("4129984562545") 7
- static combinations_range(sequence: list, *, min_len: int = 1, max_len: int = 0) list[tuple] [source]
Generate all combinations of a
sequence
frommin_len
tomax_len
- Parameters:
sequence (list) – A sequence that need to generate combination
min_len (int) – Minimum
r
ofcombinations
(Default:1
)max_len (int) – Maximum
r
ofcombinations
(Default:0
- len ofsequence
)
- Returns:
A list of all combinations from range(
min_len
,max_len
) ofsequence
- Return type:
list[tuple]
Example:
>>> Generator.combinations_range([1, 2, 3], min_len=2) [(1, 2), (1, 3), (2, 3), (1, 2, 3)]
- class absfuyu.tools.Inspector(obj: Any, *, line_length: int | None = 88, include_docs: bool = True, include_mro: bool = False, include_method: bool = False, include_property: bool = True, include_attribute: bool = True, include_private: bool = False, include_all: bool = False)[source]
Bases:
AutoREPRMixin
Inspect an object
- Parameters:
obj (Any) – Object to inspect
line_length (int | None) – Number of cols in inspect output (Split line every line_length). Set to
None
to useos.get_terminal_size()
, by default88
include_docs (bool, optional) – Include docstring, by default
True
include_mro (bool, optional) – Include class bases (__mro__), by default
False
include_method (bool, optional) – Include object’s methods (if any), by default
False
include_property (bool, optional) – Include object’s properties (if any), by default
True
include_attribute (bool, optional) – Include object’s attributes (if any), by default
True
include_private (bool, optional) – Include object’s private attributes, by default
False
include_all (bool, optional) – Include all infomation availble, by default
False
Example:
>>> print(Inspector(<object>, **kwargs))
- class absfuyu.tools.Obfuscator(code: str, *, base64_only: bool = False, split_every: int = 60, variable_length: int = 12, fake_data: bool = False)[source]
Bases:
ShowAllMethodsMixin
Obfuscate code
- Parameters:
code (str) – Code text
base64_only (bool, optional) –
True
: encode in base64 form onlyFalse
: base64, compress, rot13 (default)
split_every (int, optional) – Split the long line of code every
x
character. Minimum is1
, by default60
variable_length (int, optional) – Length of variable name (when data string split). Minimum is
7
, by default12
fake_data (bool, optional) – Generate additional meaningless data, by default
False
- LIB_BASE64_ONLY: ClassVar[list[str]] = ['base64']
- LIB_FULL: ClassVar[list[str]] = ['base64', 'codecs', 'zlib']
- SINGLE_LINE_TEMPLATE: ClassVar[Template] = <string.Template object>
- PRE_HEX_B64_TEMPLATE: ClassVar[Template] = <string.Template object>
- PRE_HEX_FULL_TEMPLATE: ClassVar[Template] = <string.Template object>
- class absfuyu.tools.StrShifter(str_to_shift: str, shift_by: int = 5)[source]
Bases:
BaseClass
Shift characters in a string by a specified number of positions.
- Parameters:
str_to_shift (str) – The string whose characters will be shifted.
shift_by (int, optional) – The number of positions to shift the characters, by default
5
.
Added in version 5.0.0
- shift_by
Submodules
- absfuyu.tools.checksum module
- absfuyu.tools.converter module
- absfuyu.tools.generator module
- absfuyu.tools.inspector module
- absfuyu.tools.keygen module
- absfuyu.tools.obfuscator module
- absfuyu.tools.passwordlib module
- absfuyu.tools.shutdownizer module
- absfuyu.tools.web module