-
Notifications
You must be signed in to change notification settings - Fork 0
/
convert.h
58 lines (44 loc) · 1.2 KB
/
convert.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include "random.h"
#define MODE_ENCRYPT 1
#define MODE_DECRYPT 2
#define MODE_FILE 4
#define MODE_TEXT 8
struct alphabet {
unsigned char* alphabet;
int length;
};
struct info {
unsigned char mode;
size_t len;
unsigned char * data;
};
/**
* Helper method to print output strings
* @param a String to print
* @param len Length of string
*/
void print_list(char* a, size_t len);
/**
* Encrypts or decrypts given data with the Ceasar-Crypt algorithm
* @param info Struct with mode, data and length of data in bytes
* @param alphabet Struct with randomized alphabet and number of characters
* @param key The key used to calculate
*/
void convert(struct info * info, struct alphabet * alphabet, unsigned char key);
/**
* Creates a completely randomly shuffled alphabet in the given mode
* @param mode Mode to generate
* @return
*/
struct alphabet * create_alphabet(int mode);
/**
* Shuffles a given alphabet using the provided seed
* @param array Array to shuffle
* @param size Size of the array
* @param seed Seed to use
*/
void shuffle_alphabet(unsigned char *array, size_t size, unsigned long long sd);