-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathb64.c
96 lines (92 loc) · 1.86 KB
/
b64.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
//In The Name Of GOD
//Writen By Ali Esmaeily
#include <stdio.h>
int strlen(char *a);
int main()
{
// General Variables
char data [] = "string";
int cont1 [] = {0,2,4,4,2,6,0};
int cont2 [] = {0,252,3,240,15,196,63};
int action_number = (2 * strlen(data));
int mem [30];
int mem1 [30];
int memptr = 1;
char b64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz"
"0123456789"
"+/";
int flag = 0;
if ((8 * strlen(data)) % 6 == 0)
flag = 1;
// Data Maker
int m = 1;
for (int i = 0;i < action_number;i++)
{
if (i % 2 == 0)
{
mem[i] = ((data[i/2] & cont2[m]) >> cont1[m]);
}
else
{
mem[i] = ((data[i/2] & cont2[m]) << cont1[m]);
}
if (m == 6)
m = 1;
else
m++;
}
/* //Debug Enviroment
for (int l = 0;l < action_number; l++)
{
printf("mem ->%d\n",mem[l]);
printf("\n");
}
*/
// Data linker
mem1[0] = mem[0];
for (int j = 1;j < action_number;j += 2)
{
if ((j + 1) % 6 == 0)
{
mem1[memptr] = mem[j];
memptr++;
j--;
}
else
{
mem1[memptr] = (mem[j] ^ mem[j + 1]);
memptr++;
}
}
// Data Printer
for (int l = 0;l < memptr;l++)
{
printf("%c",b64[mem1[l]]);
}
if (flag == 0)
printf("==");
/*
//Debug Envirment
for (int l = 0;l < action_number; l++)
{
printf("mem ->%d\n",mem[l]);
printf("mem1 ->%d\n",mem1[l]);
printf("\n");
}
*/
printf("\n\a");
return 0;
}
//Counting characters of string
int strlen(char *a)
{
int i = 0;
int res = 0;
while (*(a + i) != '\0')
{
res++;
i++;
}
return res;
}