Skip to content

Instantly share code, notes, and snippets.

View JoeAlamo's full-sized avatar

Joe Alamo JoeAlamo

  • One Utility Bill
  • Newcastle, United Kingdom
View GitHub Profile
@JoeAlamo
JoeAlamo / svg.html
Created October 25, 2016 15:41
Demo of interactive visio topology
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Ocucon Camera Topology Demo</title>
<style>
#topology-container {
width: 700px;
height: 495px;
margin-bottom: 40px;
#include <ChaChaPoly.h>
void setup() {
Serial.begin(9600);
// put your setup code here, to run once:
uint8_t key[32] = {
0x1C, 0x92, 0x40, 0xA5, 0xEB, 0x55, 0xD3, 0x8A,
0xF3, 0x33, 0x88, 0x86, 0x04, 0xF6, 0xB5, 0xF0,
0x47, 0x39, 0x17, 0xC1, 0x40, 0x2B, 0x80, 0x09,
0x9D, 0xCA, 0x5C, 0xBC, 0x20, 0x70, 0x75, 0xC0
<?php
// vectors
$key = pack('H*', '1C9240A5EB55D38AF333888604F6B5F0473917C1402B80099DCA5CBC207075C0');
$nonce = pack('H*', '0102030405060708');
$additionalData = pack('H*', 'F33388860000000000004E91');
$plaintext = pack('H*', '496E7465726E65742D4472616674732061726520647261667420646F63756D656E74732076616C696420666F722061206D6178696D756D206F6620736978206D6F6E74687320616E64206D617920626520757064617465642C207265706C616365642C206F72206F62736F6C65746564206279206F7468657220646F63756D656E747320617420616E792074696D652E20497420697320696E617070726F70726961746520746F2075736520496E7465726E65742D447261667473206173207265666572656E6365206D6174657269616C206F7220746F2063697465207468656D206F74686572207468616E206173202FE2809C776F726B20696E2070726F67726573732E2FE2809D');
$plaintextLen = mb_strlen($plaintext, '8bit');
$expectedTag = pack('H*', 'EEAD9D67890CBB22392336FEA1851F38');
$ciphertext = \Sodium\crypto_aead_chacha20poly1305_encrypt($plaintext, $additionalData, $nonce, $key);