GithubHelp home page GithubHelp logo

vertexes / esp32micropython Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lemariva/esp32micropython

0.0 0.0 0.0 31 KB

Basic functions/libraries for ESP32 running MicroPython

Home Page: https://lemariva.com/blog/2017/10/micropython-getting-started

License: Apache License 2.0

Python 100.00%

esp32micropython's Introduction

ESP32-MicroPython

Basic functions/libraries for ESP32/ESP8266 and WiPy2.0/3.0 running MicroPython.

More info: lemariva.com

ftp.py

Small FTP server

Limitations

  • Passive mode only
  • A single data connection at a time
  • Data transfer is assumed to be in binary mode (ascii setting is ignored)
  • Operation blocks the thread
  • No authentication support

Supports

  • Changing directories (cd/CWD)
  • Directory listing (ls/LIST with no parameters)
  • File retrievals (get/RETR)
  • File uploads (put/STOR)

ntptime.py

Get the epoch time from time1.google.com

timeutils.py

Implements machine.RTC() with ntp_sync(), gmtime() and formatdate() -RFC 2822 date format- as functions

md5.py

Encode a string using an MD5 algorithm.

>>> import md5
>>> md5.digest('foo')
'acbd18db4cc2f85cedef654fccc4a4d8

md5hash.py

Encode a string using an MD5 algorithm.

>>> from md5hash import md5
>>> m = md5()
>>> m.update('foo')
>>> m.hexdigest()
'acbd18db4cc2f85cedef654fccc4a4d8'

maes.py

Simple AES cipher implementation in pure Python following PEP-272 API

import maes
import ubinascii

class AESCipher():
    def __init__(self, key):
        self.bs = 16
        self.key = key

    def encrypt(self, raw):
        raw = self._pad(raw)
        cipher = maes.new(self.key, maes.MODE_ECB)
        crypted_text = cipher.encrypt(raw)
        crypted_text_b64 = ubinascii.b2a_base64(crypted_text)
        return crypted_text_b64

    def decrypt(self, enc):
        enc = ubinascii.a2b_base64(enc)
        cipher = maes.new(self.key, maes.MODE_ECB)
        raw = cipher.decrypt(enc)
        return self._unpad(raw).decode('utf-8')

    def _pad(self, s):
        padnum = self.bs - len(s) % self.bs
        return s + padnum * chr(padnum).encode()

    @staticmethod
    def _unpad(dec):
        s = bytes(bytearray(dec))
        return s[:-ord(s[len(s)-1:])]


>>> key = b'0cc103aaf3df5dff'
>>> cypher = AESCipher(key)
>>> enc = cypher.encrypt(b'foo')
>>> print(enc)
b'S8IpdJ+PpVYutZB5sWXGkA==\n'
>>> cypher.decrypt(enc)
'foo'

Changelog

Revision 0.3

License

Check files

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.