Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jieter/python-lora
Decrypt LoRa payloads in python.
https://github.com/jieter/python-lora
Last synced: 7 days ago
JSON representation
Decrypt LoRa payloads in python.
- Host: GitHub
- URL: https://github.com/jieter/python-lora
- Owner: jieter
- License: mit
- Created: 2016-03-07T10:27:45.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2024-10-28T09:50:15.000Z (3 months ago)
- Last Synced: 2024-12-29T02:24:52.143Z (14 days ago)
- Language: Python
- Homepage:
- Size: 67.4 KB
- Stars: 67
- Watchers: 13
- Forks: 18
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-lora - python-lora - Decrypt LoRa payloads in python (Tools)
README
# python-lora
Python wrapper for LoRa payloads from Thingpark/Actility, allowing decryption of the payload.
- Depends on [cryptography]
- Based on crypto code in [Lora-net/LoRaMac-node]
- Tested with python 3.8, 3.9, 3.10, 3.11
- Available on [pypi]## Usage
`pip install python-lora`
[cryptography] requires [cffi] which in turn requires `libffi-dev` and `python-dev`.
```python
from lora.payload import LoRaPayloadxmlstr = '''
[...]
2[...]
[...][...]
'''payload = LoRaPayload(xmlstr)
key = 'AABBCCDDEEFFAABBCCDDEEFFAABBCCDD'
dev_addr = '00112233'
plaintext = payload.decrypt(key, dev_addr)
```You can also use `loramac_decrypt` without the XML wrapper to decode a hex-encoded `FRMPayload`:
```python
>>> from lora.crypto import loramac_decrypt
>>> payload = '11daf7a44d5e2bbe557176e9e6c8da'
>>> sequence_counter = 2
>>> key = 'AABBCCDDEEFFAABBCCDDEEFFAABBCCDD'
>>> dev_addr = '00112233'
>>> loramac_decrypt(payload, sequence_counter, key, dev_addr)
[222, 59, 24, 8, 7, 155, 237, 158, 103, 125, 93, 34, 161, 204, 33]
```[cryptography]: https://cryptography.io/
[cffi]: https://cffi.readthedocs.org/en/latest/
[pypi]: https://pypi.python.org/pypi/python-lora
[Lora-net/LoRaMac-node]: https://github.com/Lora-net/LoRaMac-node/blob/master/src/mac/LoRaMacCrypto.c#L108