This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Program | |
{ | |
static void Main(string[] args) { | |
var secretByets = Base32Encoding.ToBytes("supersecretpassword"); | |
var input = GetEpoch() / 30; | |
var hmac = new HMACSHA1(secretByets); | |
var output = hmac.ComputeHash(toBytes(input)); | |
Console.WriteLine("{0:d6}", calculate(output)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum { BMAX = 32, BMIN = BMAX / 2, BHEIGHT = 6 }; | |
struct BNode { | |
uint32_t length; | |
Key keys[BMAX]; | |
union { | |
BNode *children[BMAX]; | |
Value values[BMAX]; | |
}; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum { BMAX = 32, BCUT = BMAX / 2, BHEIGHT = 6 }; | |
typedef uint8_t BIndex; | |
struct BNode { | |
BIndex length; | |
Key keys[BMAX]; | |
union { | |
BNode *children[BMAX]; | |
Value values[BMAX]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Build with > clang++ -std=c++17 pinger.cpp -o pinger -Wall -Werror -fsanitize=address,undefined | |
#include <arpa/inet.h> | |
#include <netdb.h> | |
#include <netinet/ip_icmp.h> | |
#include <signal.h> | |
#include <stdio.h> | |
#include <unistd.h> | |
#include <string> |