Skip to main content

Python wrapper around the libsrtp library

Project description

rtd pypi-v pypi-pyversions pypi-l pypi-wheel tests codecov

What is pylibsrtp?

pylibsrtp is a Python wrapper around libsrtp, making it possible to encrypt and decrypt Secure Real-time Transport Protocol (SRTP) packets from Python code.

SRTP is a profile of the Real-time Transport Protocol (RTP) which provides confidentiality, message authentication, and replay protection. It is defined by RFC 3711.

You can install pylibsrtp with pip:

$ pip install pylibsrtp

To learn more about pylibsrtp please read the documentation.

Example

#!/usr/bin/env python

from pylibsrtp import Policy, Session

key = (b'\x00' * 30)
rtp = b'\x80\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' + (b'\xd4' * 160)

# protect RTP
tx_policy = Policy(key=key, ssrc_type=Policy.SSRC_ANY_OUTBOUND)
tx_session = Session(policy=tx_policy)
srtp = tx_session.protect(rtp)

# unprotect RTP
rx_policy = Policy(key=key, ssrc_type=Policy.SSRC_ANY_INBOUND)
rx_session = Session(policy=rx_policy)
rtp2 = rx_session.unprotect(srtp)

# check roundtrip worked!
assert rtp2 == rtp

Building pylibsrtp

If you wish to build pylibsrtp yourself, you will need libsrtp version 2.0 or better.

On Debian/Ubuntu run:

$ apt install libsrtp2-dev

On Fedora/CentOS run:

$ dnf install libsrtp-devel

On OS X run:

$ brew install srtp

License

pylibsrtp is released under the BSD license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pylibsrtp-0.8.0.tar.gz (11.1 kB view hashes)

Uploaded source

Built Distributions

pylibsrtp-0.8.0-cp311-cp311-win_amd64.whl (46.8 kB view hashes)

Uploaded cp311

pylibsrtp-0.8.0-cp311-cp311-win32.whl (42.1 kB view hashes)

Uploaded cp311

pylibsrtp-0.8.0-cp310-cp310-win_amd64.whl (46.8 kB view hashes)

Uploaded cp310

pylibsrtp-0.8.0-cp310-cp310-win32.whl (42.1 kB view hashes)

Uploaded cp310

pylibsrtp-0.8.0-cp39-cp39-win_amd64.whl (46.8 kB view hashes)

Uploaded cp39

pylibsrtp-0.8.0-cp39-cp39-win32.whl (42.1 kB view hashes)

Uploaded cp39

pylibsrtp-0.8.0-cp38-cp38-win_amd64.whl (46.8 kB view hashes)

Uploaded cp38

pylibsrtp-0.8.0-cp38-cp38-win32.whl (42.1 kB view hashes)

Uploaded cp38

pylibsrtp-0.8.0-cp37-cp37m-win_amd64.whl (46.8 kB view hashes)

Uploaded cp37

pylibsrtp-0.8.0-cp37-cp37m-win32.whl (42.1 kB view hashes)

Uploaded cp37

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page