Skip to content

Instantly share code, notes, and snippets.

View Staars's full-sized avatar

Christian Baars Staars

View GitHub Profile
@Staars
Staars / chacha.ino
Created April 19, 2025 17:10
Test implementation chacha_poly
int32_t m_chacha20_poly_run(bvm *vm, int32_t _encrypt) {
int32_t argc = be_top(vm); // Get the number of arguments
if (argc >= 4 && be_isbytes(vm, 1) // secret_key - 32 bytes
&& be_isbytes(vm, 2) // iv/nonce - 12 bytes
&& be_isbytes(vm, 3) // data/cipher
&& be_isbytes(vm, 4) // mac/tag - 16 bytes
// optional: aad
) {
size_t key_len = 0;
@Staars
Staars / crypto_tests.be
Last active April 24, 2025 18:01
Crypto test vectors
import crypto
e = crypto.ED25519()
seed = bytes("9d61b19deffd5a60ba844af492ec2cc44449c5697b326919703bac031cae7f60")
secret_key=e.secret_key(seed)
message = bytes()
public_key = secret_key[-32..]
_public_key = bytes("d75a980182b10ab7d54bfed3c964073a0ee172f3daa62325af021a68f707511a")
assert(public_key == _public_key)
signature = e.sign(message, secret_key)
assert(signature == bytes("e5564300c360ac729086e2cc806e828a84877f1eb8e5d974d873e065224901555fb8821590a33bacc61e39701cf9b46bd25bf5f0595bbe24655141438e7a100b"))
@Staars
Staars / AudioEncoderOpus.cpp
Last active January 28, 2025 17:57
unused i2s snippet
class AudioEncoderOpus : public AudioEncoder
{
public:
AudioEncoderOpus() {
AddLog(LOG_LEVEL_DEBUG,PSTR("I2S: AudioEncoderOpus"));
headerBuffer = (uint8_t*)&combHeader;
packetno = 0;
};
virtual ~AudioEncoderOpus() {
if(inBuffer){ free(inBuffer); }
@Staars
Staars / i2s.ino
Last active January 14, 2025 13:59
some tests
/*
xdrv_42_i2s_audio.ino - Audio dac support for Tasmota
Copyright (C) 2021 Gerhard Mutz and Theo Arends
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
@Staars
Staars / timg.py
Last active December 19, 2024 14:04
GIF test
from PIL import Image, ImageSequence
import io
import requests
fname = 'img.gif'
id ='23041'
url = 'https://developer.lametric.com/content/apps/icon_thumbs/'+id+'_icon_thumb.gif'
r = requests.get(url)
open(fname , 'wb').write(r.content)
# run in lib/libesp32_div/esp-nimble-cpp/src/
import os
excludes = ["mega_header.h","NimBLEBeacon.h","NimBLEBeacon.cpp","HIDKeyboardTypes.h","HIDTypes.h","NimBLEHIDDevice.h","NimBLEHIDDevice.cpp","NimBLEEddystoneURL.h","NimBLEEddystoneURL.cpp","NimBLEEddystoneTLM.h","NimBLEEddystoneTLM.cpp"]
src_dir = os.path.join("./")
src_files=os.listdir(src_dir)
headers = [f for f in src_files if (f.endswith(".h") and f not in excludes)]
@Staars
Staars / ul_led.be
Created December 4, 2024 21:38
Animation Test
class UNANIM
var color, cycles, delay, mode
var clist
var steps
def init(color, cycles, delay, mode)
self.color = color
self.cycles = cycles
self.delay = delay
self.mode = mode
@Staars
Staars / main.c
Created November 19, 2024 14:01
Test for WS2812b, can not work
/*
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Unlicense OR CC0-1.0
*/
/* ULP-RISC-V example
This example code is in the Public Domain (or CC0 licensed, at your option.)
Unless required by applicable law or agreed to in writing, this
@Staars
Staars / nvs.be
Last active August 5, 2024 18:16
NVS parser WIP
class NC # NVS Constants
static page_size = 4096
static entry_size = 32
static item_type = {
0x01: 'uint8_t',
0x11: 'int8_t',
0x02: 'uint16_t',
0x12: 'int16_t',
0x04: 'uint32_t',
@Staars
Staars / Berry_import.md
Created July 6, 2024 16:25
more tests for the docs

Berry Python Import Assistant

<script src="../extra_javascript/python2berry.js"></script> <textarea name="python_src" id="python_src" rows="20" cols="50">Source </textarea>
Convert to Berry