Skip to content

Instantly share code, notes, and snippets.

Tim Taubert ttaubert

View GitHub Profile
View keybase.md

Keybase proof

I hereby claim:

  • I am ttaubert on github.
  • I am ttaubert (https://keybase.io/ttaubert) on keybase.
  • I have a public key whose fingerprint is B1CB F850 F25E 7B7B 8C91 9AA6 4DD9 6198 4B92 E4F2

To claim this, I am signing this object:

@ttaubert
ttaubert / rc4.js
Last active Aug 29, 2015
RC4 in (almost) a tweet
View rc4.js
function*r(k){t=x=>(y=x%n)in s?s[y]:y;w=_=>t((s[i%n]=t(j+=f=t(i++)))+(s[j%n]=f));for(n=256,s=[i=j=0];i<n;)w(j+=k[i%k.length]);for(j=0,i=1;;)yield w()}
// A raw RC4 stream.
// Works in Firefox only (needs lots of ES6).
// 150 chars
// Usage:
for (var b of r([65,65,65])) {
console.log(b);
}
@ttaubert
ttaubert / onion-gen.js
Created Nov 2, 2014
Generating custom .onion names with the WebCrypto API
View onion-gen.js
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
/*
* thirty-two
* https://github.com/chrisumbel/thirty-two
*
View add.c
#include <stdint.h>
uint8_t add(uint8_t a, uint8_t b) {
uint8_t sum = a + b;
return sum < a ? UINT8_MAX : sum;
}
View cmul.c
#include <stdint.h>
// 0xff if MSB(x) = 1 else 0x00
uint8_t msb(uint8_t x) {
return 0 - (x >> (8 * sizeof(x) - 1));
}
// 0xff if a >= b else 0x00
uint8_t nz(uint8_t x) {
return ~msb(~x & (x - 1));
You can’t perform that action at this time.