Skip to content

Add Base64 Helper Functions for Vodozemac-Olm Interoperability #16

@TrevisGordan

Description

@TrevisGordan

To streamline interoperability between Vodozemac and python-olm, introduce helper functions that handle Base64 encoding and decoding of message attributes (ciphertext, mac, ephemeral_key) directly in Rust. This will remove the need for manual encoding on the Python side and improve usability.

Current example:

vodo_encryption = PkEncryption.from_key(public_key)
vodo_message = vodo_encryption.encrypt(PLAINTEXT)

vodo_mac = base64.b64encode(vodo_message.mac).decode('ascii')
vodo_ciphertext = base64.b64encode(vodo_message.ciphertext).decode('ascii')
vodo_ephemeral_key = base64.b64encode(vodo_message.ephemeral_key).decode('ascii')

A future enhancement could add a Rust helper function to handle this encoding automatically, such as:

(ciphertext, mac, ephemeral_key) = encryption.encrypt(json.dumps(media_body).encode()).to_base64()

This would provide a clearer API, as different message encodings in use can be unclear to the user.

See: #15

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions