pynenc.serializer.pickle_serializer

Module Contents

Classes

PickleSerializer

Implements the BaseSerializer for serialization using Python’s pickle module.

API

class pynenc.serializer.pickle_serializer.PickleSerializer[source]

Bases: pynenc.serializer.base_serializer.BaseSerializer

Implements the BaseSerializer for serialization using Python’s pickle module.

This class provides methods to serialize and deserialize objects to and from strings using pickle, with the serialized data encoded in base64 for safe text transmission.

Warning

Pickle can execute arbitrary code during deserialization. Prefer JsonSerializer or JsonPickleSerializer when possible — they are safer and produce human-readable output. Use PickleSerializer when you need fast prototyping, binary payloads, or operate in a trusted environment where security risks have been assessed.

static serialize(obj: Any) str[source]

Serializes an object into a string using pickle and encodes it in base64.

Parameters:

obj (Any) – The object to serialize.

Returns:

A base64 encoded string representation of ‘obj’.

static deserialize(serialized_obj: str) Any[source]

Deserializes a base64 encoded string back into an object using pickle.

Parameters:

serialized_obj (str) – The base64 encoded string to deserialize.

Returns:

The deserialized object.