Skip to content

Instantly share code, notes, and snippets.

#include <stdint.h>
#include <stdio.h>
#define BIT64VERSION 0
/* to play with the PRESENT light-weight cipher */
/*nibble box */
uint8_t sbox[16]={0xC, 5, 6, 0xB, 9,0,0xA, 0xD,3,0xE, 0xF, 8,4,7,1,2};
uint8_t inv_sbox[16]; /* go back, computed below */
uint8_t perm_index[64]; /* bit i goes to place perm_index[i], computed below */
/* created to answer
https://crypto.stackexchange.com/questions/72900/how-are-the-four-8-bit-permutation-tables-of-present-cipher-calculated */
#include <stdint.h>
#include <stdio.h>
/*nibble box */
const uint8_t sbox[16]={0xC, 5, 6, 0xB, 9,0,0xA, 0xD,3,0xE, 0xF, 8,4,7,1,2};
static void print_table(const char *name, uint8_t t[256]){
@HendrikSikke
HendrikSikke / prob_5q.c
Created May 1, 2018 21:38
to compute problemhttps://math.stackexchange.com/questions/2759407/ on math stack exchange
#include <stdio.h>
const double student1_probs[5] = {0.3, 0.4, 0.9, 0.7, 0.1}; /* item i is P(student 1 has question i correct) */
const double student2_probs[5] = {0.4, 0.5, 0.2, 0.8, 0.1};
int main(void){
double successes1[6]= {0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
double successes2[6]= {0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
unsigned int i, b,j;
for (i=0; i < 32;i++){