List of Utils¶
This is a list of the utility functions and objects used in the pyil2.
Functions¶
- pyil2.utils.aes_decrypt(msg: bytes, key: bytes, iv: bytes) bytes ¶
AES decryptor.
- Parameters:
msg (
bytes
) – Encrypted message.key (
bytes
) – AES key.iv (
bytes
) – AES IV.
- Returns:
Decrypted message.
- Return type:
bytes
Classes¶
- class pyil2.utils.AppPermissions(app_id: int, action_ids: ~typing.List[int] = <class 'list'>)¶
- __init__(app_id: int, action_ids: ~typing.List[int] = <class 'list'>)¶
Apps permissions model.
- Parameters:
app_id (
int
) – App identifier.actions_ids ([
int
]) – List of actions.
- __str__()¶
str
: String representation of app permissionsin the JSON format (‘#<appId>[,<actionId_1>,…,<actionId_n>]’).
- classmethod resolve(permissions: str) Self ¶
Parse a string into an
AppPermissions
object.- Parameters:
permissions (
str
) – App permissions in the format used by the JSON response (‘#<appId>,<actionId_1>,…,<actionId_n>’).- Returns:
return an
AppPermissions
instance.- Return type:
- class pyil2.utils.certificates.PKCS12Certificate(path: str, password: str)¶
A PKCS12 certificate interface.
- Parameters:
path (
str
) – Path to the .pfx certificate.password (
str
) – Password of the .pfx certificate.
- property common_name: str¶
Certificate Common Name. If none found, return empty string.
- Type:
str
- decrypt(cypher_text: bytes) bytes ¶
Decode a encrypted message using RSA with SHA1.
- Parameters:
cypher_text (
bytes
) – Encrypted message.- Returns:
Decrypted message.
- Return type:
bytes
- property friendly_name: str¶
Certificate friendly name (Not implemented).
- Type:
str
- has_pk() bool ¶
Check if the certificate has a primary key.
- Returns:
True if the certificate has a primary key.
- Return type:
bool
- property key_id: str¶
Id of the key.
- Type:
str
- property private_key: bytes¶
Certificate private key.
- Type:
bytes
- property pub_key: str¶
Public key in IL2 text representation.
- Type:
str
- property pub_key_hash: str¶
Public key hash in IL2 text representation.
- Type:
str
- property public_certificate: bytes¶
Certificate public certificate.
- Type:
bytes
- property public_exponent: int¶
Public exponent.
- Type:
int
- property public_modulus: int¶
Public modulus.
- Type:
int
- class pyil2.utils.range.LimitedRange(start: int, count: int = 1, end: int = None)¶
A closed interval of integers represented by the notation ‘[start-end]’. If the range has only one value, the range is represented by ‘[start]’.
- Parameters:
start (
int
) – Initial value of the interval.count (
int
) – How many elements are in the range.end (
int
) – If defined, define the end value of the interval.
- Raises:
ValueError – If ‘count’ is 0
- start¶
Initial value of the interval
- Type:
int
- end¶
End value of the interval
- Type:
int
- __contains__(item: int | Self) bool ¶
Check if item is in self.
- Parameters:
item (
int
/LimitedRange
) – Item to check if is in self.- Returns:
Return item in self.
- Return type:
bool
- __eq__(other: Self) bool ¶
bool
: Return self == other.
- __str__() str ¶
str
: String representation of self.
- property count: int¶
Number of elements in the interval.
- Type:
int
- overlaps_with(other: Self) bool ¶
Check if there is an overlap between the intervals of self and other.
- Returns:
Return True if there is an overlap.
- Return type:
bool
- classmethod resolve(text: str) Self ¶
Parses a string into a
LimitedRange
.- Parameters:
text (
str
) – String representing the range in the format of ‘[start]’ or ‘[start-end]’.- Returns:
An instance of the LimitedRange represented by the text.
- Return type: