-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfunct2.c
61 lines (53 loc) · 1.49 KB
/
funct2.c
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
59
60
61
#include "ascrypto.h"
void reseed(void)
{
srand(time(NULL));//how the fuck do we seed rnd to time??
}
char rnd_ascii(void)
{
//return rand char in dec interval [33;126]
return ((char)(33 + (rand()/(RAND_MAX/94))));
}
int roll(int max)
{
int coef = RAND_MAX / max;
//reseed(); //how the fuck do we seed rnd to time??
return (rand()/(coef));
}
char shuffle(int c)
{
//return rand char in dec interval [33;79] or [79;126] opposite to current dec side
int tmp;
int sum;
tmp = rnd_ascii();
sum = ((c >= tmp) ? (c - tmp) : (tmp - c));
// printf("%d & %d = %d\n", c, tmp, sum);
if ((sum > 126) || (sum < 33))
return (shuffle(c));
return(tmp);
}
char *splitter(void)
{
//the splitter is a chain of 3 characters counting for 316 overall ascii dec, starting and ending with a lowercase
char *str = (char *)malloc(sizeof(char) * 4);
str[0] = 97 + roll(25);
str[2] = 97 + roll(25);
str[3] = '\0';
str[1] = 316 - (str[0] + str[2]);
return (str);
}
int pos_splitter(char *str)
{
int i;
if (!(str))
return (-1);
for (i = 0; i <= (int)strlen(str); i++)
{
// printf("%d\n", (str[i] + str[i + 1] + str[i + 2]));
if ((str[i] + str[i + 1] + str[i + 2]) == 316)
if (str[i] >= 'a' && str[i] <= 'z')
if (str[i + 2] >= 'a' && str[i + 2] <= 'z')
return (i);
}
return (-1);
}