Skip to content

A MicroPython module to encrypt and decrypt messages with AES CBC mode.

License

Notifications You must be signed in to change notification settings

jacklinquan/micropython-cryptomsg

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

micropython-cryptomsg

PyPI version Downloads

A MicroPython module to encrypt and decrypt messages with AES CBC mode.

This module only works under MicroPython and it is tested with MicroPython V1.12.

For a compatible CPython version, please find Python package cryptomsg.

Please consider Paypal Donate to support me.

Installation

>>> import upip
>>> upip.install('micropython-cryptomsg')

Alternatively just copy cryptomsg.py to the MicroPython device.

Usage

>>> from cryptomsg import CryptoMsg
>>> message = 'YOUR MESSAGE'
>>> # Use default key and iv, not secure.
>>> cipher = CryptoMsg().encrypt_msg(message)
>>> cipher
b"E\xa8\x02\x08\xa3+m\xce'1\xc2\x1c\xa3\xeb\x06\x05"
>>> CryptoMsg().decrypt_msg(cipher)
b'YOUR MESSAGE'
>>> # Only set key, and iv is the same as key.
>>> cipher = CryptoMsg(b'YOUR KEY').encrypt_msg(message)
>>> cipher
b'o\x8e\xa8\x13\xda )\x10zS\xfd\xf5\xae\x90\x95\xfb'
>>> CryptoMsg(b'YOUR KEY').decrypt_msg(cipher)
b'YOUR MESSAGE'
>>> # Set both key and iv, strongest encryption. 
>>> cipher = CryptoMsg(b'YOUR KEY', b'YOUR IV').encrypt_msg(message)
>>> cipher
b'\xbflr\xf6\xae\xc1\xf9W\xfc\xcd&\xf3R\xd3\x8b\xde'
>>> CryptoMsg(b'YOUR KEY', b'YOUR IV').decrypt_msg(cipher)
b'YOUR MESSAGE'

About

A MicroPython module to encrypt and decrypt messages with AES CBC mode.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages