Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/piaca/micropython-aes
https://github.com/piaca/micropython-aes
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/piaca/micropython-aes
- Owner: piaca
- License: mit
- Created: 2017-07-06T08:25:32.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-07-06T08:26:19.000Z (over 7 years ago)
- Last Synced: 2024-04-22T12:33:05.502Z (9 months ago)
- Language: Python
- Size: 5.86 KB
- Stars: 17
- Watchers: 3
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-micropython - micropython-aes - AES algorithm with pure python implementation. (Libraries / Communications)
README
# micropython-aes
AES algorithm with pure python implementation. Small modify based on https://github.com/ipfans/pyAES for MicroPython.
# How to use?
### In REPL
```
>>> import maes
>>> import ubinascii
>>>
>>> def array_tostring(array_data):
... _string = ""
... for _array in array_data:
... _string = _string + chr(_array)
... return _string
...
>>>
>>> key = b"1234567890abcdef"
>>> iv = b"1234567890abcdef"
>>>
>>> cryptor = maes.new(key, maes.MODE_CBC, IV=iv)
>>> ciphertext = cryptor.encrypt(b'This is a test! What could possibly go wrong?___')
>>> print(ubinascii.b2a_base64(array_tostring(ciphertext)))
b'wo3DsMKeDTd0DXcUw4wlwq0zwrMmL8O6SxdyNsOFIcKmXk/Dty0PInYswrzCssOGwpkWATlzw54Bw6XChXXDm2ca\n'
>>>
>>> decryptor = maes.new(key, maes.MODE_CBC, IV=iv)
>>> print(array_tostring(decryptor.decrypt(ciphertext)))
This is a test! What could possibly go wrong?___
>>>
```### In nodemcu with micropython
1. Fetch source code `https://github.com/micropython/micropython`
2. put `maes.py` to directory `$MICROPYTHON_DIR/esp8266/modules`
3. build firmware and flash into nodemcu### Why?
Cause MicroPython don't support AES algorithm.