bmp.c 1.5 KB
Newer Older
Jakub Čirip's avatar
Jakub Čirip committed
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
97
98
99
100
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include "bmp.h"
#include "playfair.h"



char* reverse(const char* text)
{
	
	
	int ls = 0;
	int ps = strlen(text) - 1;

if(text!=NULL)
{
	while (ls < ps)
	{
		char a = text[ls];
		text[ls] = text[ps];
		text[ps] = a;
		ls++;
		ps--;
	}
//	printf("%s", text);
	 return text;
}
else
return NULL;

}

char* vigenere_encrypt(const char* key, const char* text)
{
	char encrypt[100];
	int number[26]={ 0,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};
	
	for(int i=0; i<=strlen(text); i++)
	{
		int result=0, resultt=0;
		int pocet=0, pocett=0;
		while(text[i]!=ALPHA[pocet]){
			pocet++;
		}
		while(key[i]!=ALPHA[pocett]){
			pocett++;
		}
		result = number[pocet]+number[pocett];
		if(result>26){
			resultt= result-26;
		}
		else{
			resultt = result;
		}
		
		ALPHA[resultt] = encrypt[i];
	
	}
	return encrypt;
}

char* vigenere_decrypt(const char* key, const char* encrypt)
{
	char dencrypt[100];
	int number[26]={ 0,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};
	
	for(int i=0; i<=strlen(encrypt); i++)
	{
		int result=0, resultt=0;
		int pocet=0, pocett=0;
		while(encrypt[i]!=ALPHA[pocet]){
			pocet++;
		}
		while(key[i]!=ALPHA[pocett]){
			pocett++;
		}
		result = number[pocet]-number[pocett];
		if(result<0){
			resultt= result+26;
		}
		else{
			resultt = result;
		}
		
		ALPHA[resultt] = dencrypt[i];
	
	}
	return dencrypt;
}

unsigned char* bit_encrypt(const char* text)
{
	
}

char* bit_decrypt(const unsigned char* text)
{
	
}