The BaseSecret class and related functions#
Related module: pyzora.secret
- pyzora.secret.parse_secret(secret_string: str, region: GameRegion) → bytearray#
Convert a secret string into a byte array.
- Parameters:
secret_string (str) – The secret string to convert.
region (GameRegion) – The game region to use. Be aware that not setting the correct region before parsing might net you some unexpected errors.
- Raises:
SecretError – if the secret string contains invalid symbols.
- Returns:
The converted array.
- Return type:
bytearray
- pyzora.secret.create_string(data: bytearray, region: GameRegion) → str#
Produces a secret string from a byte array with a given region.
- Parameters:
data (bytearray) – The array to convert.
region (GameRegion) – The game region to use during conversion.
- Raises:
SecretError – if the byte array contains invalid values.
- Returns:
The data converted to a string using the given encoding.
- Return type:
str
- pyzora.secret.calculate_checksum(secret: bytearray) → int#
Calculate the checksum for a given secret.
- Parameters:
secret (bytearray) – The secret a checksum needs to be calculated for.
- Returns:
The needed checksum integer.
- Return type:
int
- pyzora.secret.Byte(integer: str) → int#
Return a byte integer from a bitstring.
- Parameters:
integer (str) – The bitstring to convert.
- Returns:
The corresponding byte integer.
- Return type:
int
- class pyzora.secret.BaseSecret#
Base secret class for all secret objects.
This class contains all base methods other secret classes can rely on. It should not be instantiated directly.
This class defines a basic __hash__ method, but said hash will be different depending on the secret class.
- property game_id#
The secret’s game ID. A game ID is generated upon creating a normal save file in either Ages or Seasons, and is kept when using a secret to start a linked save in the other game. After being first input through the Labrynna/Holodrum secret, this ID will be compared against further secret inputs’ game IDs, which means that all further secrets will have to use the same ID.
- Type:
int
- property region#
The secret’s region. It’s needed to parse correctly data for a given secret string.
- Type:
- classmethod decode_bytes(secret: bytearray | str, region: GameRegion) → bytearray#
Decode a parsed secret string or byte array using a certain region.
- Parameters:
secret (bytearray or str) – The secret to decode, either as a string or a byte array.
region (GameRegion) – The region to use.
- Returns:
The decoded byte array.
- Return type:
bytearray