public
Last active

a block cipher in one tweet

  • Download Gist
simeck.cpp
C++
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#include <stdio.h>
#include <stdint.h>
 
// the tweet starts
#define S(x,r)((x<<r)|(x>>(64-r)))
#define R(l,r,k)l=S(l,5)&l^S(l,1)^k;r^=l;l^=r;
#define E(l,r,k0,k)for(int i=0;i<45;){R(k0,k,i++)R(l,r,k)}
// the tweet ends
 
int main() {
uint64_t data[2] = {1, 2};
uint64_t key[2] = {3, 4};
 
E(data[0], data[1], key[0], key[1]);
printf("%llx, %llx\n", data[0], data[1]);
 
return 0;
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.